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 (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Oct 2009 15:05:19 -0400
Reply-To:     msz03@albany.edu
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mike Zdeb <msz03@ALBANY.EDU>
Subject:      Re: Output statement problem in array
Content-Type: text/plain;charset=iso-8859-1

hi ... I think this is less complicated than what you are doing

proc sql; create table stats as select sex, catx(' ', put(mean(height),6.2),'+/-',put(std(height),6.2)) as height length=25, catx(' ', put(mean(weight),6.2),'+/-',put(std(weight),6.2)) as weight length=25 from sashelp.class group sex; quit;

proc transpose data=stats out=tstats (rename=(col1=stat)) name=measure; by sex; var height weight; run;

proc print data=tstats; run;

Obs Sex measure stat 1 F height 60.59 +/- 5.02 2 F weight 90.11 +/- 19.38 3 M height 63.91 +/- 4.94 4 M weight 108.95 +/- 22.73

then if you still want two data sets ...

data male (keep=measure male) female (keep=measure female); set tstats; select (sex); when ('F') do; female=stat; output female; end; when ('M') do; male=stat; output male; end; end; run;

-- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

> Dear listers, > > I am trying to re-organize my the output data from proc means and here are > the data(named MNs below)look like: > > sex Wt_kg_Mean Wt_kg_StdDev BMI_Mean BMI_StdDev > 0 83.72496865 9.259684431 27.82611859 3.337137114 > 1 67.35882123 13.42571627 25.59401365 4.211461117 > > I am trying to transpose into colmns with mean ± std by sex. Below is my > code for it: > > %LET Std= Age_StdDev Wt_kg_StdDev BMI_StdDev; > %LET VName= Age_Mean Wt_kg_Mean BMI_Mean; > > DATA MNs_M(Keep=Measure Male) MNs_F(Keep=Measure Female); > SET MNs; > ARRAY VarN {*} &VarsN; > ARRAY VarsName {*} &VName ; > ARRAY VarStd {*} &Std; > > DO I = 1 to DIM(VarN); > Measure=VNAME(VarN(I)); > IF SEX=0 THEN DO; > Male=CAT(ROUND( VarsName(I), .1), ' ± ', ROUND(VarStd(I), .1)); > OUTPUT; > END; > IF SEX=1 THEN DO; > Female= CAT(ROUND(VarsName(I), .1), ' ± ', ROUND(VarStd(I), .1)); > OUTPUT; > END; > END; > IF SEX=0 THEN OUTPUT MNs_M; > ELSE OUTPUT MNs_F; > RUN; > > The re-organized data look like this: > > Measure Male > > Wt_kg 82.5 ± 13.4 > BMI 26.2 ± 3 > BMI 26.2 ± 3 > > Wt_kg > BMI > > As you can see, BMI, which is the last variable repeated output twice, what > step should I take to avoid this problem? > > Thanks in advance, > Sophia >


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