DATA Step, Macro, Functions and more

How do I definte a new variable? Death within 1 year after chemo therapy

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

How do I definte a new variable? Death within 1 year after chemo therapy

hello, 

 

I am trying to definte a new variable as "Death within 1 year after chemo therapy" using the following dataset...

 

Both patient_ID 10001 and 10002 has death_dates, but only patient_ID 10001 should be marked dead within 1 year because the death_date falls within 1 year after First_Chemo_Date whereas patient ID 10002 does not.

 

-----------------------------------------------------------------------

Patient_ID      First_Chemo_Date           Death_Date 

10001                  2010-05-01                  2010-08-01

10002                  2010-07-01                  2012-05-01

------------------------------------------------------------------------

 

using previous help from generous members of this community, I tried the following.

 

data w.cancer;

set w.cancer;

 

IF (FIRST_CHEMO_DATE<DEATH_DATE<FIRST_CHEMO_DATE+365) THEN DEATH_WITHIN_1YR_AFTER_CHEMO=1; ELSE IF

DEATH_WITHIN_1YR_AFTER_CHEMO=0;

run;

 

However, it is not giving me the result that I want...what am I doing wrong here?

 

Any help or advice will be appreciated so much..,

 

 


Accepted Solutions
Solution
‎08-03-2016 12:21 AM
Super User
Posts: 17,737

Re: How do I definte a new variable? Death within 1 year after chemo therapy

SAS treats dates as numbers so if you subtract the dates that should be the number of days between chemo and death. 

View solution in original post


All Replies
Solution
‎08-03-2016 12:21 AM
Super User
Posts: 17,737

Re: How do I definte a new variable? Death within 1 year after chemo therapy

SAS treats dates as numbers so if you subtract the dates that should be the number of days between chemo and death. 

Contributor
Posts: 23

Re: How do I definte a new variable? Death within 1 year after chemo therapy

I reformatted my dates and it works now. Thank you for your advice!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 184 views
  • 0 likes
  • 2 in conversation