BookmarkSubscribeRSS Feed
Almighty
Fluorite | Level 6

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

3 REPLIES 3
Almighty
Fluorite | Level 6

Can any body reply please

Haikuo
Onyx | Level 15

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;

Astounding
PROC Star

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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