Date: Mon, 3 Jan 2011 17:55:52 -0600
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: the compute block in proc report
In-Reply-To: <001301cbab9f$c260e1b0$4722a510$@com>
Content-Type: text/plain; charset=ISO-8859-1
Max, I haven't read Cody's book, but it's simple: You must reference the
column with an appropriate type of DEFINE statement in order to use it later
on in a COMPUTE block; otherwise SAS doesn't know to prepare it for use.
PROC REPORT is a funny procedure, in particular because it was written
largely to be used interactively, and has a lot of nuances to learn.
Note in the pdf you attached that the author had DEFINE statements for every
COLUMN variable referenced. Any that are utilized but not printed can be
defined as DISPLAY NOPRINT, which will not actually display the variable,
but still make it available for use. It's sort of counterintuitive, but
nonetheless true.
Thanks,
Joe
On Mon, Jan 3, 2011 at 5:41 PM, bbser 2009 <bbser2009@gmail.com> wrote:
> Joe
>
>
>
> I guess your example might be from Cody's book, where the author seemly did
> not mention anything why we need to "display" weight.
> Following your suggestion, I found several papers like this one
> http://support.sas.com/resources/papers/proceedings10/141-2010.pdf,
>
> but still did not find the answer.
>
>
>
> I was wondering, would it be possible for me to ask you to explain this to
> me? I am kind of in a hurry for the certification exam. Thanks a lot.
>
>
>
> Max
>
>
>
> *From:* Joe Matise [mailto:snoopy369@gmail.com]
> *Sent:* January-03-11 6:07 PM
> *To:* bbser 2009
> *Cc:* SAS-L@listserv.uga.edu
>
> *Subject:* Re: the compute block in proc report
>
>
>
> The answer you seek is found in this code...
>
>
> proc report data=sashelp.class nowd;
> column name weight weight_kg;
> define name /order;
> define weight_kg/computed;
> compute weight_kg;
> weight_kg=weight/2.2;
> endcomp;
> run;
>
> proc report data=sashelp.class nowd;
> column name weight weight_kg;
> define name /order;
>
> define weight/display;
> define weight_kg/computed;
> compute weight_kg;
> weight_kg=weight/2.2;
> endcomp;
> run;
>
> I recommend reading some of the basic PROC REPORT SUGI papers; there are
> some excellent ones that go into detail as to the intricacies and just plain
> weird aspects of PROC REPORT, which are often not immediately logical (for
> example, why does ANALYSIS preclude a variable from being used in this
> fashion, but DISPLAY allows it?).
>
> -Joe
>
> On Mon, Jan 3, 2011 at 4:56 PM, bbser 2009 <bbser2009@gmail.com> wrote:
>
> After running the code below,
> all values of ratio were 0 and in the log I got a note "Variable timemin is
> uninitialized".
> I checked the data set stress and found the variable timemin (not a label)
> was right there.
> I was totally confused by this result. Please help. Thanks a lot.
>
> Happy New Year.
> Max
>
> -----------------------------------
>
> proc sort data=clinic.stress out=stress;
> by testlength;
> run;
>
> proc report nowd data=stress;
> column testlength timemin ratio;
> define testlength / order;
> define ratio / computed;
> compute ratio;
> ratio=timemin/2;
> endcomp;
> run;
>
>
>
|