BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi. I am trying to create a summary dataset of the following:
var1 var2 var3 var4 var5
var1 is the main variable and vars2-5 contain text values. What I would like is a report that shows the frequencies of var2 values against var1, var3 against var1, etc.

Proc Freq summarised the frequencies nicely one variable at a time BUT there are 50 vars and this method created 50 different datasets which is not practical to work with. Is there a way of doing this in one step and creating only one dataset? I have a feeling Proc Tabulate might do the trick, but I am struggling as I cannot put var2-5 under VAR as they are text fields and classing them with var1 creates a complex cross-matrix that does not give me what I need (unless there is a trick with the syntax in Proc Tabulate). Any ideas?
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
Have you tried the LIST option with PROC FREQ?????

[pre]
ods output list=work.freqlist;
proc freq data=sashelp.shoes;
tables region*product product*subsidiary/list;
run;

proc print data=work.freqlist;
run;

[/pre]

The output from this job is too lengthy to show here, but you get a flat list for the first table region*product and then another flat list for product*subsidiary. The information for each crossing is differentiated by a TABLE variable that shows which table statement created the observation. In addition, you can sometimes get the kind of summarizing you want from PROC MEANS. I'm not sure you need TABULATE...although, TABULATE will allow you to nest or cross character variables but you are limited to the N or PCTN statistic.

[pre]

proc tabulate data=sashelp.shoes;
class region product subsidiary;
table region*product,n;
run;
[/pre]

cynthia
deleted_user
Not applicable
Hi Cynthia
The LIST method is what I need! The resulting dataset will need some cleaning up, but this is very much what I was looking for. So simple, thanks.
Cheers, Rob

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1043 views
  • 0 likes
  • 2 in conversation