Help using Base SAS procedures

help with generate more time points in the data

Reply
N/A
Posts: 0

help with generate more time points in the data

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;
Trusted Advisor
Posts: 2,113

Re: help with generate more time points in the data

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.
N/A
Posts: 0

Re: help with generate more time points in the data

Hi Doc@Duke:

It works. Thanks a lot.
Ask a Question
Discussion stats
  • 2 replies
  • 76 views
  • 0 likes
  • 2 in conversation