I am having difficulty in calculating study day, the raw date is like below:
asessmentday Event
05May2012 Screening
12May2012 Dose1
13may2012 sampling
15may2012 analysis
16may2012 result
The output should be looks like below: Study_day = 05May2012 - 12May2012 = -7
Study_day= 13May2012 - 12May2012 = 1
study_day asessmentday Event
-7 05May2012 Screening
1 12May2012 Dose administration
2 13may2012 sampling
3 15may2012 analysis
4 16may2012 result
Please help me with the code.
Thanks
Suresh
Can any body reply please
Try this: although I believe you should have the same criteria for both before and after day1. But if not, it can be easily adjusted.
data have;
input asessmentday :date9. Event :$15.;
format asessmentday date9.;
cards;
05May2012 Screening
12May2012 Dose1
13may2012 sampling
15may2012 analysis
16may2012 result
02May2012 Screening
10May2012 Dose1
16may2012 sampling
19may2012 analysis
23may2012 result
;
data want (drop=_:);
length event $15.;
do until (event='result');
set have;
if event='Dose1' then _d=asessmentday;
end;
do until (event='result');
set have;
study_day=asessmentday-_d+1;
output;
end;
run;
proc print;run;
Don't you really have data for many patients, and a variable like Patient_ID?
In your example, should May 15 really be study day 3, or should it be study day 4?
The programming can actually be quite simple, but you have to present us with the real problem.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.