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

Hi Everyone I have come across an issue that I was hoping someone could help me solve. I have a data set with 120 observations. I would like to see how many times various combinations of five variables present themselves within the data. According to my calculations there are 31 possible unique combinations of the 5 variables. What I would like to see is how many times each of these 31 combinations are present within these 120 observations. A table of the possible combinations is listed with the 5 variables represented as A, B, C, D, and E.  Any help would be greatly appreciated!

 

 


combo.JPG
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

This should do it:

 

proc freq data=have;

tables a * b * c * d * e / missing list;

run;

 

The number of combinations of values could be much larger depending on what values your variables take on.  But you'll see that soon enough.

 

Good luck.

View solution in original post

2 REPLIES 2
Reeza
Super User
What does your data actually look like? You can calculate the number of combinations via the comb() function.

data have;
do i=1 to 5;
x=comb(5,i);
y=sum(x,y);
output;
end;
run;

proc print data=have;run;

Counting the instances may be as simple as a proc freq.
Astounding
PROC Star

This should do it:

 

proc freq data=have;

tables a * b * c * d * e / missing list;

run;

 

The number of combinations of values could be much larger depending on what values your variables take on.  But you'll see that soon enough.

 

Good luck.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3477 views
  • 1 like
  • 3 in conversation