BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Dear SAS users:

I hope to get some help for adding more data points in the data set.

My data file is like following:

ID TIME CONC. AGE WEIGHT
1 0 10 22 70
2 0 11 24 65
3 0 9 33 71
4 0 8 31 66

Every ID only has one CONC. at TIME=0. I'd like to add more TIME points eg. 0, 1, 2, 3, 4 ..to 100 for every ID. So the final format should look like:

ID TIME CONC. AGE WEIGHT
1 0 10 22 70
1 1 10 22 70
1 2 10 22 70
...
2 0 11 24 65
2 1 11 24 65
2 2 11 24 65

...
3 0 9 33 71
3 1 9 33 71
3 2 9 33 71
...
4 0 8 31 66
4 1 8 31 66
4 2 8 31 66
...

I was trying to use DO LOOP, change the TIME and use SET to merge the data. The code is listed below. But I have not succeeded. As then number in do loop increase, I get less and less observations in the data set. Thanks in advance.



filename datain
'E:\\pk.csv';

data fulldata;
infile datain DELIMITER=',';
input ID TIME CONC AGE WEIGHT;
if ID EQ _blank_ THEN delete;
drop _blank_;
run;

data pk1;
set fulldata;
run;

data pkn;
do i=1 to 100 ;
set pk1;
TIME=TIME+i;
end;
run;
2 REPLIES 2
Doc_Duke
Rhodochrosite | Level 12
Rewrite your last step to

data pkn;
set pk1;
OUTPUT;
do i=1 to 100 ;
TIME=TIME+i;
OUTPUT;
end;
run;

Note the re-arrangement and the addition of the two OUTPUT statements. The first one outputs the original record and the second one outputs the 100 synthetic records.
deleted_user
Not applicable
Hi Doc@Duke:

It works. Thanks a lot.

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
  • 2 replies
  • 775 views
  • 0 likes
  • 2 in conversation