LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2001, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 16 Nov 2001 11:16:36 -0500
Reply-To:     "Huang, Ya" <ya.huang@PFIZER.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Huang, Ya" <ya.huang@PFIZER.COM>
Subject:      Re: Q on proc report, compute block?
Comments: To: Perry Watts <wattsp@DCA.NET>
Content-Type: text/plain; charset="iso-8859-1"

Perry,

Thanks for the suggestion. I believe the macro trick will work. But I still don't understand why mine did not work. According to the Online Doc the syntax for compute block is:

compute after <target>

and if <target> is omitted, the compute block should be excute at the end of report. And there is also an example in Online Doc for that.

Richard Read Allen in a private response provide me another trick, that is to add a dummy var, and change "compute after" to "compute after dummy". It works too.

I'm lost.

Ya Huang

-----Original Message----- From: Perry Watts [mailto:wattsp@DCA.NET] Sent: Thursday, November 15, 2001 8:44 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Q on proc report, compute block?

Ya Huang, I think your problem is in the COMPUTE AFTER; -- You are literally "computing after" i.e. after you have read through the entire data set -- so that all variables are re-set to missing. I can see where you cannot literally do computations in this PROC REPORT, since you need medians. I got around this problem by substituting macro variables for your Temp1 data set containing ON1, OM1, OM2. Please see below. Perry

data xx; input study $ sex $ age ncrs desc $; cards; B F 67 8 stst B F 34 10 sdfsaf B M 55 7 sdryts B M 73 7 werwer B M 46 9 sdgsf A M 45 3 abcd A M 65 4 bdrf A F 46 3 lsdfsd A F 67 5 sdfas ;

proc sort; by study;

proc univariate noprint data=xx; by study; var age ncrs; output out=temp n=n1 median=m1 m2;

proc univariate noprint data=xx; var age ncrs; output out=temp1 n=on1 median=om1 om2;

proc sql noprint; select left(put(on1,3.)), left(put(om1,5.1)), left(put(om2,5.1)) into :on1, :om1, :om2 from temp1; quit;

data xx; merge xx temp; by study;

/**** SKIP THIS: proc sql; create table xx as select xx.*, temp1.* from xx, temp1 order by study ; ***/

options nocenter; proc report data=xx nowd headline; column n1 m1 m2 study sex age ncrs desc; define study / width=5 order; define sex / width=3 order; define age / width=3; define ncrs / width=5; define n1/noprint order; define m1/noprint order; define m2/noprint order; compute after study; line ' '; line 'N=' n1 3.; line 'Median age=' m1 5.1; line 'Median CRS=' m2 5.1; line ' '; endcomp; compute after; line ' '; line "Total N= &on1"; line "Overall Median age= &om1"; line "Overall Median CRS= &om2"; line ' '; endcomp; run;

/************************** Output:

study sex age ncrs desc -------------------------------- A F 46 3 lsdfsd 67 5 sdfas M 45 3 abcd 65 4 bdrf

N= 4 Median age= 55.5 Median CRS= 3.5

B F 67 8 stst 34 10 sdfsaf M 55 7 sdryts 73 7 werwer 46 9 sdgsf

N= 5 Median age= 55.0 Median CRS= 8.0

Total N= 9 Overall Median age= 55.0 Overall Median CRS= 7.0 ****************************/

-------------------------- Perry Watts wattsp@dca.net --------------------------


Back to: Top of message | Previous page | Main SAS-L page