turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Variable Combination Count

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-21-2015 03:03 PM

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!

Accepted Solutions

Solution

12-21-2015
03:54 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-21-2015 03:18 PM

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.

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-21-2015 03:15 PM

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.

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.

Solution

12-21-2015
03:54 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

12-21-2015 03:18 PM

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.