Contributor
Posts: 37

# Study Day Calculation problem

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

2                13may2012     sampling

3                15may2012     analysis

4                16may2012     result

Thanks

Suresh

Contributor
Posts: 37

Posts: 3,167

## Re: Study Day Calculation problem

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;

Super User
Posts: 6,753

## Re: Study Day Calculation problem

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.

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