Help using Base SAS procedures

Study Day Calculation problem

Reply
Contributor
Posts: 34

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

1                12May2012     Dose administration

2                13may2012     sampling

3                15may2012     analysis

4                16may2012     result

Please help me with the code.

Thanks

Suresh

Contributor
Posts: 34

Re: Study Day Calculation problem

Can any body reply please

Respected Advisor
Posts: 3,156

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=_Smiley Happy;

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: 5,513

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.

Ask a Question
Discussion stats
  • 3 replies
  • 1078 views
  • 0 likes
  • 3 in conversation