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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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