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! 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 491 views
  • 1 like
  • 2 in conversation