Date: Fri, 13 Jul 2007 12:15:57 -0400
Reply-To: "Gerstle, John (CDC/CCID/NCHHSTP) (CTR)" <yzg9@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Gerstle, John (CDC/CCID/NCHHSTP) (CTR)" <yzg9@CDC.GOV>
Subject: Re: Processing Dozens of Vars in Proc Freq
In-Reply-To: <000701c7c562$817ae410$44407997@econ.ers.usda.gov>
Content-Type: text/plain; charset=us-ascii
Go for something like this (I like using ODS OUTPUT):
Ods output onewayfreqs=out_table ;
Proc freq data=started;
Tables v1 v2 v3 v4 v5 / missing nocum ;
Run;
Ods output close;
This will create a dataset containing each of the one way frequencies
appended to one another. You'll need to play a bit to collapse all the
variables into one column.
Another way, would be:
%macro freq_loop;
%let vars = v1 v2 v3 v4 v5;
%do I = 1 % to 5;
%let var=%scan(&vars,&i);
Ods output onewayfreqs=out_table_&i (rename=(&var=variable));
Proc freq data=started;
Tables &var / missing nocum ;
Run;
Ods output close;
%if &i=1 %then %do;
Data final; set out_table_1; run;
%end;
%else %do;
Data final; set final out_table_&i; run;
%end;
%mend;
%freq_loop;
Then take the resulting Final dataset, and use your favorite reporting
PROC, PRINT, REPORT, TABULATE, etc. Can always make it prettier...
John Gerstle
MS Applied Neuroscience, MS Applied Statistics
Biostatistician
Northrop Grumman
CDC Information Technological Support Contract (CITS)
NCHSTP \DHAP \HICSB \Research and Dissemination Team
Centers for Disease Control and Prevention
yzg9 at cdc dot gov
>>-----Original Message-----
>>From: owner-sas-l@listserv.uga.edu
[mailto:owner-sas-l@listserv.uga.edu]
>>On Behalf Of David Hopkins
>>Sent: Friday, July 13, 2007 11:29 AM
>>To: sas-l@listserv.uga.edu
>>Subject: Processing Dozens of Vars in Proc Freq
>>
>>Dear SAS-L,
>>
>>I need to analyze dozens of vars with Proc Freq. For each var, I need
all
>>of the values for the var, totals for each value, and percentages for
each
>>value. I do not need any of the more exotic statistics from Proc
Freq.
>>
>>And from this processing, I need an OUTPUT SAS dataset to pass the
>>information over to other processes.
>>
>>Can this be done?
>>
>>So far, the documentation says I will only get OUTPUT from one var,
the
>>last var that was typed in. Is this true? Can I get one large SAS
OUTPUT
>>dataset with the answers to all of my dozens of vars?
>>
>>Is there any other Proc that can give you Proc Freq processing, with
>>multiple vars and give you an OUTPUT SAS dataset?
>>
>>Any help would be appreciated.
>>
>>
>>I was expecting Proc Freq to be a little more friendly.
>>
>>
>>
>>
>>--David Hopkins
>> DHopkins@email.ers.usda.gov
>>
>> Cool web site: www.ers.usda.gov
|