BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasworker16
Calcite | Level 5

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..,

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

2 REPLIES 2
Reeza
Super User

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

sasworker16
Calcite | Level 5

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 997 views
  • 0 likes
  • 2 in conversation