BookmarkSubscribeRSS Feed
sasques
Calcite | Level 5
Hi

I would like to convert a table that contains count data into a dataset that contains individual observations but I'm not sure how

For example, I would like to convert a table that looks like this

X Y count
1 3 2
2 6 4
5 4 3

into a dataset that looks like this

X Y
1 3
1 3
2 6
2 6
2 6
2 6
5 4
5 4
5 4

Does anyone know of a SAS code that can carry out this conversion?

Thanks!
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
DATA step with a KEEP and SET statement. And you would add a DO UNTIL (); / END; loop containing an OUTPUT statement. With the expression, you reference variable COUNT.

Scott Barry
SBBWorks, Inc.

Recommended Google advanced search argument, this topic/post:

data step programming do loop output site:sas.com
deleted_user
Not applicable
Hello friend,

Try checking this code.
As Scott suggested the right method to do this.

data test;
input x y count;
cards;
1 3 2
2 6 4
5 4 3
;
run;

data new (drop= i count) ;
set test;
i=count;
do until (i=0);
output;
i=i-1;
end;
run;


Thanks,
Saurabh.
sasques
Calcite | Level 5
Thanks everyone -- these suggestions are helpful.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1000 views
  • 0 likes
  • 3 in conversation