BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bncoxuk
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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

4 REPLIES 4
SteveDenham
Jade | Level 19

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.

andreas_lds
Jade | Level 19

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;

data_null__
Jade | Level 19

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;

bncoxuk
Obsidian | Level 7

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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