| Date: | Wed, 9 Feb 2011 10:41:08 -0800 |
| Reply-To: | Jack <jacksas001@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Jack <jacksas001@GMAIL.COM> |
| Subject: | Re: PROC REPORT - Compute confusion |
| In-Reply-To: | <AANLkTi=nsMr5EdGaPcpKFW7fPuaJxLpX53JpKGjM4EjZ@mail.gmail.com> |
| Content-Type: | text/plain; charset=ISO-8859-1; format=flowed |
Hi Sterling
Since Report procedure will define variables in order, please switch
"iyrmo" and "amt amt2" in both COLUMN and DEFINE statements. It should
works.
proc report missing data = have;
columns amt amt2 irymo;
define amt / display;
define amt2 / display;
define iyrmo / display;
compute amt2;
if amt< 0.5 and amt2< 0.5 then
iyrmo = .;
endcomp;
run;
Zhaoyan Diao
On 2/9/2011 8:38 AM, Sterling Paramore wrote:
> After some finagling, I found that this worked too:
>
>
> proc report missing data = have;
> columns iyrmo amt amt2;
>
> define iyrmo / display;
> define amt / display;
> define amt2 / display;
>
> compute amt2;
> if amt< 0.5 and amt2< 0.5 then
> iyrmo = .;
> endcomp;
>
> run;
>
> which seemed counter-intuitive to me because I assumed "compute amt2" would
> mean "compute the value of amt2." From this example, "compute amt2" seems
> to mean "compute something when the variable amt2 is read."
>
>
> On Tue, Feb 8, 2011 at 6:23 PM, Data _null_;<iebupdte@gmail.com> wrote:
>
>
>> And if you want to have you cake and eat it too, use an alias in the
>> COLUMN statement.
>>
>> data have;
>> do iyrmo = 200901 to 200912;
>> amt = uniform(-1);
>> amt2 = uniform(-1);
>> output;
>> end;
>> run;
>>
>> proc report nowd list missing data = have out = wtf;
>> columns amt amt2 iyrmo amt=aamt amt2=aamt2;
>> define amt / display noprint;
>> define amt2 / display noprint;
>> define iyrmo / display;
>> define aamt / display;
>> define aamt2 / display;
>>
>> compute iyrmo;
>> if amt< 0.5 and amt2< 0.5 then
>> iyrmo = .;
>> endcomp;
>>
>> run;
>>
>> On Tue, Feb 8, 2011 at 7:56 PM, Joe Matise<snoopy369@gmail.com> wrote:
>>
>>> Reverse the column order and I think it will work as you expect.
>>>
>>> proc report missing data = have out = wtf nowd;
>>> columns amt amt2 iyrmo;
>>> define iyrmo / display;
>>>
>>> define amt / display;
>>> define amt2 / display;
>>>
>>> compute iyrmo;
>>> if amt< 0.5 and amt2< 0.5 then
>>> iyrmo = .;
>>> endcomp;
>>>
>>> run;
>>>
>>> PROC REPORT only has access to variables to the left of the COMPUTE
>>>
>> variable
>>
>>> in a compute block, if I recall correctly.
>>>
>>> -Joe
>>>
>>> On Tue, Feb 8, 2011 at 6:46 PM, Sterling Paramore<gnilrets@gmail.com
>>> wrote:
>>>
>>>
>>>> Dear SAS-L,
>>>>
>>>> This is a bit of a contrived example, but I can't figure out why all
>>>>
>> iyrmo
>>
>>>> always show up as null?
>>>>
>>>> data have;
>>>> do iyrmo = 200901 to 200912;
>>>> amt = uniform(-1);
>>>> amt2 = uniform(-1);
>>>> output;
>>>> end;
>>>> run;
>>>>
>>>> proc report missing data = have out = wtf;
>>>> columns iyrmo amt amt2;
>>>>
>>>> define iyrmo / display;
>>>> define amt / display;
>>>> define amt2 / display;
>>>>
>>>> compute iyrmo;
>>>> if amt< 0.5 and amt2< 0.5 then
>>>> iyrmo = .;
>>>> endcomp;
>>>>
>>>> run;
>>>>
>>>>
>>>
>>
|