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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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