|
|
|
|
|
e*******e 发帖数: 75 | 1 Hi,
I have a dataset as follows:
patient_ID drug drug_start_date drug_end_date
1 A 1/1/2011 1/6/2011
1 A 2/1/2011 2/4/2011
1 B 1/1/2010 1/2/2010
1 B 5/3/2010 5/6/2010
2 C 1/2/2011 1/5/2011
2 C 3/3/2011 3/4/2011
2 A 3/4/2010 3/5/3010
3 A 2/1/2011 2/1/2011
3 A 1/15/2010 1/17/2010
4 A 3/2/2010 3/5/2010
4 B 4/2/2010 4/2/2010
I want to transform the dataset as follows:
patient_ID drug drug_use_date
1 A 1/1/2011
1 A 1/2/2011
1 A 1/3/2011
1 A 1/4/2011
1 A 1/5/2011
1 A 1/6/2011
1 A 2/1/2011
1 A 2/2/2011
1 A 2/3/2011
1 A 2/4/2011
1 B 1/1/2010
1 B 1/2/2010
1 B 5/3/2010
1 B 5/4/2010
1 B 5/5/2010
1 B 5/6/2010
2 C 1/2/2011
2 C 1/3/2011
2 C 1/4/2011
2 C 1/5/2011
2 C 3/3/2011
2 C 3/4/2011
2 A 3/4/2010
2 A 3/5/2010
3 A 2/1/2011
3 A 1/15/2010
3 A 1/16/2010
3 A 1/17/2010
4 A 3/2/2010
4 A 3/3/2010
4 A 3/4/2010
4 A 3/5/2010
4 B 4/2/2010
in the above dataset, all the drug use date are laid out day by day from the
drug start date till drug end date from the original dataset.
Would you please help to transform from the original dataset to the above
one? Many thanks,
| l*******s 发帖数: 6 | 2 proc sort data=a;
by patient_id drug drug_start_date;
run;
data b;
set a;
by patient_id drug drug_start_date;
do drug_use_date=drug_start_date to drug_end_date by 1;
output;
end;
format drug_use_date mmddyy10.;
run; |
|
|
|
|
|