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 (August 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 21 Aug 2009 16:27:07 -0700
Reply-To:     xlr82sas <xlr82sas@AOL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         xlr82sas <xlr82sas@AOL.COM>
Subject:      Re: Getting SAS to Display Combinations of Values not in the Data
Comments: To:
Content-Type: text/plain; charset=ISO-8859-1

On Aug 21, 1:39 pm, pjmiller...@YAHOO.COM (Paul Miller) wrote: > Hi Mike, Mark, Carol, and "Data _Null_", > =A0 > Thanks for your helpful responses. I've been trying to use preloadfmt to di= > splay the missing categories. I've pasted the code I have=A0 below.=20 > =A0 > One problem I've run into is that I don't really want to tabulate all possi= > ble combinations. I just want to tabulate all possible relationships betwee= > n study drug and race where patients actually experienced a given adverse e= > vent.=20 > =A0 > Is there any way to make preloadfmt and completerows display all possible c= > ombinations when ae =3D "Yes" but not otherwise? Or would adding=A0a relati= > onship to drug categories table to my sql code then joining where ae =3D "'= > Yes" be more likely to give me the kind of control I need? > =A0 > Thanks, > =A0 > Paul > =20 > **** Get frequency counts; > =A0 > proc sql; > create table freqs as > select compbl(t1.cycle_label||' (N =3D '||put(t1.cycle_freq,3.)||')') as cy= > cle_freq, > t2.neutropeniayn, t2.ae_freq, t3.neutropeniadrug, t3.race, t3.related_freq= > =20 > from (select cycle_label, count(distinct subject_number) as cycle_freq=20 > from adverse_events group by cycle_label) as t1, > > (select cycle_label, neutropeniayn, count(distinct subject_number) as ae_fr= > eq > from adverse_events group by cycle_label, neutropeniayn) as t2, > (select cycle_label, neutropeniayn, neutropeniadrug, race, count(distinct s= > ubject_number) as related_freq > from adverse_events group by cycle_label, neutropeniayn, neutropeniadrug, r= > ace) as t3 > where t1.cycle_label =3D t2.cycle_label and=20 > t2.cycle_label =3D t3.cycle_label and t2.neutropeniayn =3D t3.neutropeniayn= > ; > quit; > =A0 > **** Create Word Table; > options missing=3D'_'; > ods escapechar =3D '^'; > ods listing close; > ods msoffice2k file=3D'N:\B001\Output\Test.doc' style=3Dminimal; > proc report data=3Dfreqs(where=3D(neutropeniayn =3D 'yes' or neutropeniadru= > g =3D '')) nowindows completerows split=3D"|" style(report)=3D{font_size=3D= > 10pt} missing; > column cycle_freq neutropeniayn ae_freq neutropeniadrug race total; > define cycle_freq / group order=3Dformatted 'Event Cycle' style(header) =3D= > [vjust=3Dcenter just=3Dleft] style(column) =3D [just=3Dleft cellwidth=3D3.= > 5 in]; > define neutropeniayn / group order=3Dformatted 'Neutropenia' style(header) = > =3D [vjust=3Dcenter] style(column) =3D [cellwidth=3D1 in] format=3D$folicyn= > ..; > define ae_freq / group order=3Dformatted 'N' style(header) =3D [vjust=3Dcen= > ter] style(column) =3D [just=3Dcenter cellwidth=3D1 in]; > define neutropeniadrug/ group order=3Dformatted 'Related' style(header) =3D= > [vjust=3Dcenter just=3Dleft] style(column) =3D [just=3Dleft cellwidth=3D2.= > 5 in] format=3D$related. preloadfmt; > define race / across '' style(column) =3D [just=3Dcenter cellwidth=3D2.5 in= > ] format=3D$race.; > define total / computed 'Total' style(column) =3D [just=3Dcenter cellwidth= > =3D2.5 in]; > freq related_freq; > compute total; > total =3D sum(_c5_,_c6_,_c7_,_c8_); > endcomp; > > break after neutropeniayn / summarize suppress; > break after cycle_freq / summarize style=3D{foreground=3Dwhite}; > title '^S=3D{font_size=3D14pt} Table 185. Summary of Neutropenia by Race'; > run; > ods msoffice2k close; > ods listing;=0A=0A=0A ________________________________________________= > __________________=0AYahoo! Canada Toolbar: Search from anywhere on the web= > , and bookmark your favourite sites. Download it now=0Ahttp://ca.toolbar.ya= >

Just to thow out some related techniques to make this thread a little richer.

The method below is not as good as good as preloadformat, but it does create some 0 cells and does balance the data.

proc freq data=sashelp.class; tables sex*age / sparse list missing; run;

Sex Age Frequency ------------------------ F 11 1 F 12 2 F 13 2 F 14 2 F 15 2 F 16 0 M 11 1 M 12 3 M 13 1 M 14 2 M 15 2 M 16 1

As a side note allperm and choose? function will give you combinations but interchanging position in a list is generally not what you want

data test; drop i perms; length new $200; array x (4) $16 ('Male' 'Female' 'White' 'Non White'); /* Create a new variable of the concatenated results */ perms=fact(4); do i=1 to perms; call allperm(i, of x(*)); new=cats(of x(*)); output; end; run; proc print; run;

x1 x2 x3 x4

Male Female White Non White Male Female Non White White Male Non White Female White Non White Male Female White Non White Male White Female Male Non White White Female Male White Non White Female

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