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

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          

vital_status1 initial_dx_date1 date_of_death1 date_last_fu_or_d1
108/02/2016.10/13/2017
002/25/201007/15/201007/15/2010
007/05/2010.08/14/2011
002/21/201207/11/201207/11/2012
003/24/2014.10/10/2014
102/03/2014.01/25/2018
101/30/2017.02/22/2018
006/15/201210/22/201310/22/2013
011/20/200906/10/201006/10/2010
010/21/201010/11/201510/11/2015
011/22/201107/28/201407/28/2014
105/22/2012.02/18/2014
007/08/201311/24/201311/24/2013
010/02/201312/25/201412/25/2014
005/17/201109/09/201609/09/2016
005/05/201109/10/201309/10/2013
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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));

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

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));

lady8506
Quartz | Level 8

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!

novinosrin
Tourmaline | Level 20

Lol I have had those moments too. Have a good day 🙂

PaigeMiller
Diamond | Level 26

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));

 

--
Paige Miller

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 933 views
  • 2 likes
  • 3 in conversation