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

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1875 views
  • 0 likes
  • 3 in conversation