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

Feel free to direct my to an article or post if this has been discussed previously.

 

I'd like to create a table that replicates an observation based on a frequency count. While I'm able to use the frequency (or weight) command for many functions, it would be nice to have a full cross-tabulation of the data as well. A sample of my data would be:

 

Have:

GroupEventStudyCount
1113
1012
0114

 

Want:

 

GroupEventStudy
111
111
111
101
101
011
011
011
011

 

I used low frequencies here but my frequencies are actually in the hundreds or thousands. My inkling is that I should be using an array within a data step but I haven't figured it out yet.

 

I appreciate any answers! I'm keen to learn different potential approaches as well. 

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ
data have;
input
Group	Event	Study	Count;
cards;
1	1	1	3
1	0	1	2
0	1	1	4
;
run;
data want(drop=count i); 
 set have;
 do i=1 to count;
  output;
 end;
run;
/* end of program */

View solution in original post

2 REPLIES 2
sbxkoenk
SAS Super FREQ
data have;
input
Group	Event	Study	Count;
cards;
1	1	1	3
1	0	1	2
0	1	1	4
;
run;
data want(drop=count i); 
 set have;
 do i=1 to count;
  output;
 end;
run;
/* end of program */
culliso3
Fluorite | Level 6

Wow, I was way overthinking this. Thank you! 

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

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1080 views
  • 1 like
  • 2 in conversation