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
SAS Super FREQ
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

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 642 views
  • 0 likes
  • 2 in conversation