Here's my code below. Whenever I run it, the duration variable counts 0 for every observation in my dataset. Not sure why it's not calculating the duration in months between a patient's initial diagnosis date and the date of their death. Can someone take a look at my code and tell me if they see something wrong?
DATA survival_analysis; SET pancreas_temp4; duration = INTCK("DTMONTH", initial_dx_date1, coalesce(date_of_death1, date_last_fu_or_d1)); put duration = ; IF vital_status1 = 0 or not missing(date_of_death1) then censored = 1; ELSE IF vital_status1 = 1 then censored = 0; LABEL duration = "Duration in Months"; RUN;
And here is a clip of the SAS log file:
537 DATA survival_analysis; SET pancreas_temp4;
538
539 duration = INTCK("DTMONTH", initial_dx_date1, coalesce(date_of_death1,
539! date_last_fu_or_d1));
540 put duration = ;
541
542 IF vital_status1 = 0 or not missing(date_of_death1) then censored = 1;
543 ELSE IF vital_status1 = 1 then censored = 0;
544
545 LABEL duration = "Duration in Months";
546 RUN;
duration=0
duration=0
duration=0
duration=0
duration=0
duration=0
duration=0
duration=0
duration=0
duration=0
duration=0
duration=0
See all those lovely zeros? Why?! I checked all my dates and they are all the same format MMDDYY10, so I am not sure what's wrong. Any help is appreciated.
Also, here is some sample data. 1 = alive, 0 = dead
1 | 08/02/2016 | . | 10/13/2017 |
0 | 02/25/2010 | 07/15/2010 | 07/15/2010 |
0 | 07/05/2010 | . | 08/14/2011 |
0 | 02/21/2012 | 07/11/2012 | 07/11/2012 |
0 | 03/24/2014 | . | 10/10/2014 |
1 | 02/03/2014 | . | 01/25/2018 |
1 | 01/30/2017 | . | 02/22/2018 |
0 | 06/15/2012 | 10/22/2013 | 10/22/2013 |
0 | 11/20/2009 | 06/10/2010 | 06/10/2010 |
0 | 10/21/2010 | 10/11/2015 | 10/11/2015 |
0 | 11/22/2011 | 07/28/2014 | 07/28/2014 |
1 | 05/22/2012 | . | 02/18/2014 |
0 | 07/08/2013 | 11/24/2013 | 11/24/2013 |
0 | 10/02/2013 | 12/25/2014 | 12/25/2014 |
0 | 05/17/2011 | 09/09/2016 | 09/09/2016 |
0 | 05/05/2011 | 09/10/2013 | 09/10/2013 |
HI @lady8506 If your date values are SAS dates and not datetime why use DTMONTH
You should prolly use 'MONTH'
duration = INTCK("MONTH", initial_dx_date1, coalesce(date_of_death1,
539! date_last_fu_or_d1));
HI @lady8506 If your date values are SAS dates and not datetime why use DTMONTH
You should prolly use 'MONTH'
duration = INTCK("MONTH", initial_dx_date1, coalesce(date_of_death1,
539! date_last_fu_or_d1));
Ha! Silly me! I knew it was something stupid that I was missing. Sometimes you can't see the forest through the trees! Thanks so much. This fixed the problem!
Lol I have had those moments too. Have a good day 🙂
Your data is SAS dates, not SAS date-time values. So you don't want to use DTMONTH in INTCK, you want to use MONTH
duration = INTCK("MONTH", initial_dx_date1, coalesce(date_of_death1, date_last_fu_or_d1));
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.