Help using Base SAS procedures

How to summarize the frequency distribution for all variables

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 131
Accepted Solution

How to summarize the frequency distribution for all variables

Hi,

I want to summarize the frequency distribution for all the nominal variables in a dataset. Suppose the four nominal variables are: age (Y, M, O), sex (M, F), marriage (S, D, M, C), status (H, M, L). You can see here each nominal variable has multiple levels, My task is to summarize the frequency for each level of the variables. I don't want to use separate steps of PROC FREQ or PROC SUMMARY to do this. I want to get the results in a single procedure and save the results in a data set.

Thanks for help.


Accepted Solutions
Solution
‎07-11-2011 08:00 AM
Respected Advisor
Posts: 3,777

How to summarize the frequency distribution for all variables

I like the stacked tables produced by PROC FREQ.

ods listing close;

proc freq data=sashelp.class;

   tables sex age;

   ods output OneWayFreqs=Freq;

   run;

ods output close;

ods listing;

proc print;

   run;

View solution in original post


All Replies
Respected Advisor
Posts: 2,655

How to summarize the frequency distribution for all variables

I think PROC MEANS would give everything you need.

proc means data=have noprint;

class age sex marriage status;

var variablename; /*put in all that you need here*/

output out=want;

run;

Look at work.want.  The _FREQ_ variable will give the counts, _TYPE_ would give all the possible combinations, so that you could slice and dice as needed.

Super Contributor
Posts: 265

How to summarize the frequency distribution for all variables

Without any example data given this is just a blind guess:

proc summary data=work.bob;

     class age sex marriage status;

     output out=work.frequencies;

run;

Solution
‎07-11-2011 08:00 AM
Respected Advisor
Posts: 3,777

How to summarize the frequency distribution for all variables

I like the stacked tables produced by PROC FREQ.

ods listing close;

proc freq data=sashelp.class;

   tables sex age;

   ods output OneWayFreqs=Freq;

   run;

ods output close;

ods listing;

proc print;

   run;

Frequent Contributor
Posts: 131

How to summarize the frequency distribution for all variables

Hi everyone,

Thanks for help. I tried every answer and all worked. So all are correct answer. The forum system cannot give me the rating of correct answer for all responses. So I just randomly pick one and make the others as helpful.

Smiley Happy

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 506 views
  • 6 likes
  • 4 in conversation