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 (June 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 20 Jun 2008 10:05:26 -0500
Reply-To:     "data _null_," <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_," <datanull@GMAIL.COM>
Subject:      Re: How to dynamically run a array ??
Comments: To: SAS_learner <proccontents@gmail.com>
In-Reply-To:  <c2192a610806200739p577150fdu79083faa70c2d105@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On 6/20/08, SAS_learner <proccontents@gmail.com> wrote: > hello _null_, > > when I trying to do Proc Freq calculation as per your suggestion there is > huge difference between the number of observation that Proc Freq is giving > me.I do not understand what is difference between using ods output > crossTabFreqs to ordinary proc Freq ,

The ODS OUTPUT data set contains the all values from the frequency tables. Including the margins. This is not the same data as OUT=. Thus the number of observations would be expected to be different.

> > Well does your logic ( ods output crossTabFreqs ) Complains when there is > Just one variable in table statement. Can any body point me where I can get > the _type_ information using Proc freq ??

When there is only ONE variable in the TABLES statement proc freq does not produce a "cross tabulation" therefore no CROSSTABFREQS. That ODS ouput table is OneWayFreqs. Use ODS TRACE <ON/OFF>; to determine the table names.

Using this example...

tables trtgrp1*atctext*generic

_type_ will have three digits. The values correspond to the variables in the TABLES statement reading left to right. '111' involves all three variables '110' is trtgrp1*atctest totaled over generic. You should study the data sets in comparison to the tables produce by PROC FREQ that will help you understand the data better.

This does not look like the problem you asked about before. It would be helpful if you could related this question either to example data or back to there original data. I am a puzzled by the variable TRTGRP1 does 1 imply that this is just the data from level 1 of trtgrp.

> > > > options source ; > 1954 proc freq data=dblaxC ; > 1955 tables trtgrp1*atctext*generic / out= A_C_dblaxC1 > (drop=percent) > 1955! noprint; > 1956 run; > > NOTE: There were 80 observations read from the data set WORK.DBLAXC. > NOTE: The data set WORK.A_C_DBLAXC1 has 66 observations and 4 variables. > NOTE: PROCEDURE FREQ used (Total process time): > real time 0.03 seconds > cpu time 0.03 seconds > > > 1957 > 1958 > 1959 proc freq data=dblaxC ; > 1960 tables trtgrp1*atctext*generic ; > 1961 ods output crossTabFreqs = A_C_dblaxC1_new ; > 1962 run; > > NOTE: The data set WORK.A_C_DBLAXC1_NEW has 7482 observations and 11 > variables. > NOTE: There were 80 observations read from the data set WORK.DBLAXC. > NOTE: PROCEDURE FREQ used (Total process time): > real time 0.06 seconds > cpu time 0.06 seconds > > > > On Wed, Jun 18, 2008 at 2:23 PM, data _null_, <datanull@gmail.com> wrote: > > > The "best" way is "don't use arrays" and don't but data into macro > > variables and don't transpose until it is time or at all. > > > > You could use the untransposed data directly in PROC REPORT using > > across. I transpose and use PROC PRINT but you get the idea. > > > > proc format; > > value $sex 'M'='Male' 'F'='Female' 'T'='Total'; > > run; > > Proc freq data=sashelp.class; > > tables age*sex / sparse; > > ods output crossTabFreqs=freq; > > run; > > proc print; > > run; > > ** add N= to format so proc transpose can make meta data from data.; > > data work.sex; > > retain fmtname 'sexN' type 'C'; > > set freq(where=(_type_ eq: '0')); > > if _type_ eq '00' then sex='T'; > > start = sex; > > label = > put(sex,$sex.)||'~(N='||trim(put(frequency,f8.-l))||')'; > > run; > > proc format cntlin=work.sex; > > run; > > data display; > > set freq(where=(_type_ eq: '1')); > > length display $13; > > pct = coalesce(colPercent,percent); > > display = put(frequency,3.)||' ('||put(pct,5.1)||'%)'; > > if _type_ eq '10' then sex='T'; > > length idlabel $40; > > idlabel = put(sex,$sexN.); > > run; > > proc transpose out=display; > > by age; > > var display; > > id sex; > > idlabel idlabel; *this is important, you get meta data(labels) from > data; > > run; > > Proc print split='~'; > > id age; > > var M F T; > > run; > > > > > > > > > > > > On 6/18/08, SAS_learner <proccontents@gmail.com> wrote: > > > hello guys, > > > I have a dataset like Cm3 like this now > > > > > > _1 _2 _3 > > > 1 2 3 > > > 6 3 1 > > > 3 3 3 > > > 6 3 1 > > > 3 3 3 > > > 1 2 3 > > > > > > and I am following code to get the Percents and % to that count. Now my > > > problem is that this code has to changed every time there is increment > in > > > the treatment group and I had to increase or decrease the row number ?? > Can > > > I tell the SAS to look out how many variables that are starting _ and > run > > > the following code any Ideas. > > > > > > data aaa; > > > length grp1 grp2 grp3 allgrp $20.; > > > set cm3 (keep= _:) ; > > > > > > _total=sum(_1,_2,_3);/*Need to Pick the number of individual treatment > */ > > > > > > array _dgrp(4) _1 _2 _3 _total; > > > array _grppc(4) grppc1 - grppc3 allgrppc; > > > array _grp(4) $ grp1 - grp3 allgrp; > > > array _d (4) _d1 -_d4 (&d1 &d2 &d3 &dtotal); > > > > > > do i=1 to 4; > > > _grppc(i)=round(_dgrp(i)/_d(i)*100,.1); > > > _grp(i)=put(_dgrp(i),3.)||' ('||put(_grppc(i),5.1)||'%)'; > > > end; > > > run; > > > > > > thanks > > > > > > >


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