Prev: Using a Colon (:) wildcard at beginning of variable lists
Next: Problems with ODS PDF bookmarks in 9.2
From: Toby Dunn on 12 Jan 2010 15:43 ODS Output Table should do it: ODS Listing Close ; ODS Output OneWayFreqs = Freqs ; Proc Freq Data = SASHELP.CLASS ; Table _ALL_ ; Run ; ODS Listing ; Proc Print Data = Freqs ; Run ; On Tue, 12 Jan 2010 15:06:01 -0500, saslearn chicago <sasswamy(a)GMAIL.COM> wrote: >Thanks Art, >I could output the result to a data set , but only few fields. > >Can anyone let me know , whether it is possible to output all the field to >a output data set >when I tired , I am able to get only the first 3 variable , I wanted the >cumulative records and the cumulative percentage >( as it looks in the ouput window ) > >Do I need to go with a different approach ? >Please Advice, >- swamy. > >On Mon, Jan 11, 2010 at 6:18 PM, Arthur Tabachneck <art297(a)netscape.net>wrote: > >> If you only want frequency and percent then you could use: >> >> proc freq data=sashelp.class; >> weight height; >> table age/out=want; >> run; >> >> Otherwise, there is always ODS. >> >> Art >> -------- >> On Mon, 11 Jan 2010 18:04:23 -0500, SAS Swamy <sasswamy(a)GMAIL.COM> wrote: >> >> >Hello, >> > >> >This might be a simple PROC question , >> >By using PROC FREQ, I have got the result I am looking for, but not sure >> >how do I output to a data set. >> >Do I need to use BY variable , If I need to use OUT=data set name >> > >> > proc freq data=map1; >> > weight cnt; >> > table week; >> >run; >> > >> > The FREQ Procedure >> > >> >Cumulative Cumulative >> > Week Frequency Percent Frequency Percent >> > >> ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ >> > 0 4 33.33 4 33.33 >> > 1 7 58.33 11 91.67 >> > 2 1 8.33 12 100.00 >> > >> > >> >Please Advice. >> >Swamy >>
From: Mary on 12 Jan 2010 15:48 You can do this with ODS, though if you really have a lot of variables, doing one variable at a time inside a macro and then accumulating the results may get you closer to what you want for final output than ods output from prof freq: ods output variables=variables; proc contents data=transposed_outset; run; proc sql noprint; select variable into :variables separated by ' ' from variables where variable not in ('_NAME_') order by num; quit; %put &variables; ods output onewayfreqs=onewayfreqs; proc freq data=transposed_outset; tables &variables; run; -Mary --- sasswamy(a)GMAIL.COM wrote: From: saslearn chicago <sasswamy(a)GMAIL.COM> To: SAS-L(a)LISTSERV.UGA.EDU Subject: PROC Freq - Output All Variables Date: Tue, 12 Jan 2010 15:06:01 -0500 Thanks Art, I could output the result to a data set , but only few fields. Can anyone let me know , whether it is possible to output all the field to a output data set when I tired , I am able to get only the first 3 variable , I wanted the cumulative records and the cumulative percentage ( as it looks in the ouput window ) Do I need to go with a different approach ? Please Advice, - swamy. On Mon, Jan 11, 2010 at 6:18 PM, Arthur Tabachneck <art297(a)netscape.net>wrote: > If you only want frequency and percent then you could use: > > proc freq data=sashelp.class; > weight height; > table age/out=want; > run; > > Otherwise, there is always ODS. > > Art > -------- > On Mon, 11 Jan 2010 18:04:23 -0500, SAS Swamy <sasswamy(a)GMAIL.COM> wrote: > > >Hello, > > > >This might be a simple PROC question , > >By using PROC FREQ, I have got the result I am looking for, but not sure > >how do I output to a data set. > >Do I need to use BY variable , If I need to use OUT=data set name > > > > proc freq data=map1; > > weight cnt; > > table week; > >run; > > > > The FREQ Procedure > > > >Cumulative Cumulative > > Week Frequency Percent Frequency Percent > > > Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ' > > 0 4 33.33 4 33.33 > > 1 7 58.33 11 91.67 > > 2 1 8.33 12 100.00 > > > > > >Please Advice. > >Swamy >
From: Mary on 12 Jan 2010 16:11 Here's a macro approach- note that you put the variables you don't want to include in the "not in" statment in the Proc SQL, then I'm manipulating the ODS output to get everything into the same columns. This should work with lots of variables. -Mary ods output variables=variables; proc contents data=transposed_outset; run; proc sql noprint; create table variables_to_process as select variables.variable from variables where variable not in ('ID') order by num; quit; data variables_to_process; set variables_to_process; runnum + 1; run; %macro get_freqs; data results_all; informat variable $50. value $50. frequency best32. percent best32. cumfrequency best32. cumpercent best32.; stop; run; proc sql noprint; select max(runnum) into :max from variables_to_process; quit; %do i=1 %to &max; proc sql noprint; select variable into :variable from variables_to_process where runnum=&i; quit; %put processing variable: &variable; ods output onewayfreqs=onewayfreqs; proc freq data=transposed_outset; tables &variable; run; data results; informat variable $50. value $50. frequency best32. percent best32. cumfrequency best32. cumpercent best32.; set onewayfreqs; variable="&variable"; value=&variable; keep variable value frequency percent cumfrequency cumpercent; run; proc append base=results_all data=results; run; %end; %mend get_freqs; %get_freqs; --- sasswamy(a)GMAIL.COM wrote: From: saslearn chicago <sasswamy(a)GMAIL.COM> To: SAS-L(a)LISTSERV.UGA.EDU Subject: PROC Freq - Output All Variables Date: Tue, 12 Jan 2010 15:06:01 -0500 Thanks Art, I could output the result to a data set , but only few fields. Can anyone let me know , whether it is possible to output all the field to a output data set when I tired , I am able to get only the first 3 variable , I wanted the cumulative records and the cumulative percentage ( as it looks in the ouput window ) Do I need to go with a different approach ? Please Advice, - swamy. On Mon, Jan 11, 2010 at 6:18 PM, Arthur Tabachneck <art297(a)netscape.net>wrote: > If you only want frequency and percent then you could use: > > proc freq data=sashelp.class; > weight height; > table age/out=want; > run; > > Otherwise, there is always ODS. > > Art > -------- > On Mon, 11 Jan 2010 18:04:23 -0500, SAS Swamy <sasswamy(a)GMAIL.COM> wrote: > > >Hello, > > > >This might be a simple PROC question , > >By using PROC FREQ, I have got the result I am looking for, but not sure > >how do I output to a data set. > >Do I need to use BY variable , If I need to use OUT=data set name > > > > proc freq data=map1; > > weight cnt; > > table week; > >run; > > > > The FREQ Procedure > > > >Cumulative Cumulative > > Week Frequency Percent Frequency Percent > > > Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ'Æ' > > 0 4 33.33 4 33.33 > > 1 7 58.33 11 91.67 > > 2 1 8.33 12 100.00 > > > > > >Please Advice. > >Swamy >
From: Mary on 12 Jan 2010 16:29 The main problem with this approach is that SAS creates a new column for each variable's values; that's what the code that I showed with the macro is attempting to correct (puts them all in the column value); so if there were 6000 variables in the real data set; the code below would create 6000 columns for each of the variables to hold the values that the frequencies are on (even if they are the same, such as Likert Scale or Genetic markers). -Mary --- tobydunn(a)HOTMAIL.COM wrote: From: Toby Dunn <tobydunn(a)HOTMAIL.COM> To: SAS-L(a)LISTSERV.UGA.EDU Subject: Re: PROC Freq - Output All Variables Date: Tue, 12 Jan 2010 15:43:06 -0500 ODS Output Table should do it: ODS Listing Close ; ODS Output OneWayFreqs = Freqs ; Proc Freq Data = SASHELP.CLASS ; Table _ALL_ ; Run ; ODS Listing ; Proc Print Data = Freqs ; Run ; On Tue, 12 Jan 2010 15:06:01 -0500, saslearn chicago <sasswamy(a)GMAIL.COM> wrote: >Thanks Art, >I could output the result to a data set , but only few fields. > >Can anyone let me know , whether it is possible to output all the field to >a output data set >when I tired , I am able to get only the first 3 variable , I wanted the >cumulative records and the cumulative percentage >( as it looks in the ouput window ) > >Do I need to go with a different approach ? >Please Advice, >- swamy. > >On Mon, Jan 11, 2010 at 6:18 PM, Arthur Tabachneck <art297(a)netscape.net>wrote: > >> If you only want frequency and percent then you could use: >> >> proc freq data=sashelp.class; >> weight height; >> table age/out=want; >> run; >> >> Otherwise, there is always ODS. >> >> Art >> -------- >> On Mon, 11 Jan 2010 18:04:23 -0500, SAS Swamy <sasswamy(a)GMAIL.COM> wrote: >> >> >Hello, >> > >> >This might be a simple PROC question , >> >By using PROC FREQ, I have got the result I am looking for, but not sure >> >how do I output to a data set. >> >Do I need to use BY variable , If I need to use OUT=data set name >> > >> > proc freq data=map1; >> > weight cnt; >> > table week; >> >run; >> > >> > The FREQ Procedure >> > >> >Cumulative Cumulative >> > Week Frequency Percent Frequency Percent >> > >> ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ >> > 0 4 33.33 4 33.33 >> > 1 7 58.33 11 91.67 >> > 2 1 8.33 12 100.00 >> > >> > >> >Please Advice. >> >Swamy >>
From: Toby Dunn on 12 Jan 2010 17:43 Mary, I wasnt aware that all the varibales had to be in one column but its pretty darn easy to fix: ODS Listing Close ; ODS Output OneWayFreqs = Freqs ; Proc Freq Data = SASHELP.CLASS ; Table _All_ ; Run ; ODS Listing ; Data Need ( Keep = VarName Value Percent CumPercent Frequency CumFrequency ) ; Length VarName $ 32 ; Set Freqs ; VarName = Scan( Table , 2 , ' ' ) ; Value = Strip( VValueX( VarName ) ) ; Run ; Proc Print Data = Need ; Run ; Now I have the added benefit of a normalized data set with both formatted and unformatted values to grab from inorder to create the final file. On Tue, 12 Jan 2010 13:29:42 -0800, Mary <mlhoward(a)AVALON.NET> wrote: >The main problem with this approach is that SAS creates a new column for each variable's values; that's what the code that I showed with the macro is attempting to correct (puts them all in the column value); so if there were 6000 variables in the real data set; the code below would create 6000 columns for each of the variables to hold the values that the frequencies are on (even if they are the same, such as Likert Scale or Genetic markers). > >-Mary > >--- tobydunn(a)HOTMAIL.COM wrote: > >From: Toby Dunn <tobydunn(a)HOTMAIL.COM> >To: SAS-L(a)LISTSERV.UGA.EDU >Subject: Re: PROC Freq - Output All Variables >Date: Tue, 12 Jan 2010 15:43:06 -0500 > >ODS Output Table should do it: > >ODS Listing Close ; > >ODS Output OneWayFreqs = Freqs ; >Proc Freq > Data = SASHELP.CLASS ; > Table _ALL_ ; >Run ; > >ODS Listing ; > >Proc Print > Data = Freqs ; >Run ; > > > >On Tue, 12 Jan 2010 15:06:01 -0500, saslearn chicago <sasswamy(a)GMAIL.COM> >wrote: > >>Thanks Art, >>I could output the result to a data set , but only few fields. >> >>Can anyone let me know , whether it is possible to output all the field >to >>a output data set >>when I tired , I am able to get only the first 3 variable , I wanted the >>cumulative records and the cumulative percentage >>( as it looks in the ouput window ) >> >>Do I need to go with a different approach ? >>Please Advice, >>- swamy. >> >>On Mon, Jan 11, 2010 at 6:18 PM, Arthur Tabachneck ><art297(a)netscape.net>wrote: >> >>> If you only want frequency and percent then you could use: >>> >>> proc freq data=sashelp.class; >>> weight height; >>> table age/out=want; >>> run; >>> >>> Otherwise, there is always ODS. >>> >>> Art >>> -------- >>> On Mon, 11 Jan 2010 18:04:23 -0500, SAS Swamy <sasswamy(a)GMAIL.COM> >wrote: >>> >>> >Hello, >>> > >>> >This might be a simple PROC question , >>> >By using PROC FREQ, I have got the result I am looking for, but not >sure >>> >how do I output to a data set. >>> >Do I need to use BY variable , If I need to use OUT=data set name >>> > >>> > proc freq data=map1; >>> > weight cnt; >>> > table week; >>> >run; >>> > >>> > The FREQ Procedure >>> > >>> >Cumulative Cumulative >>> > Week Frequency Percent Frequency Percent >>> > >>> ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ >>> > 0 4 33.33 4 33.33 >>> > 1 7 58.33 11 91.67 >>> > 2 1 8.33 12 100.00 >>> > >>> > >>> >Please Advice. >>> >Swamy >>>
|
Next
|
Last
Pages: 1 2 Prev: Using a Colon (:) wildcard at beginning of variable lists Next: Problems with ODS PDF bookmarks in 9.2 |