I need help with setting up my dataset to perform survival analysis with a time-dependent covariate. I read the Therneau et al. paper but I'm still unsure of how to set up the counting process format for my data.
Below is a test dataset similar to what I have.
Data: Liver transplant dataset where some patients are in group 1 (if on immunosuppressive drug A at baseline), others are in group 2 (if on drug B at baseline).
Goal: I want to know how/if the time of first switch from med A to med B impacts graft survival (graft failure is the event of interest). The expectation is that the switch to drug B wouldn't significantly impact graft survival but it's important to show this because drug B would be preferable as it has less side effects, better tolerance profile and is more cost effective than drug A.
GROUP=1, if on drug A; 2 if on drug B, and 3 if they switched from A to B;
CENSOR=1, if event (graft failure) happened, 0 otherwise;
FUTIME = total follow-up time (months) (=CENSDATE – transplant date), where CENSDATE is either date of event, or date of last follow-up/death)
SWITCHTIME=time of first switch from group 1 to group 2 (=date when they switch– transplant date); this will be 0 for those patients who start off on drug B at baseline, and it is FUTIME for those who start off on drug A and never switch (per investigators's request).
data have;
input ID$ TRANSDATE:mmddyy. CENSDATE:mmddyy. FUTIME CENSOR SWITCHTIME GROUP$;
format TRANSDATE mmddyy10. CENSDATE mmddyy10.;
datalines;
001 7/2/2002 7/11/2003 344 1 344 1
002 8/23/2001 7/30/2002 311 0 311 1
003 3/27/2002 10/1/2007 1984 1 1984 1
004 1/28/2000 3/26/2011 4045 1 0 2
005 8/6/2002 12/16/2005 1198 0 1198 1
006 1/23/2001 9/8/2005 1659 0 12 3
007 4/10/2003 3/10/2006 1035 0 1035 1
008 8/26/2002 3/26/2008 2009 0 2009 1
009 8/14/2014 9/15/2016 733 0 18 3
010 11/3/2000 11/10/2003 1072 0 1072 1
011 4/11/2001 9/12/2007 2315 0 2315 1
012 2/5/2002 1/2/2006 1397 0 1397 1
013 7/11/2000 1/2/2008 2701 0 0 2
014 5/7/2002 11/10/2008 2349 0 2349 1
015 9/23/2001 2/7/2005 1203 0 6 3
016 5/3/2000 3/26/2003 1027 0 1027 1
017 3/25/2003 12/20/2006 1336 1 1336 1
018 6/24/2004 12/7/2006 866 0 866 1
019 3/22/2006 2/17/2012 2128 0 13 3
020 5/27/2000 11/14/2006 2332 0 2332 1
021 8/23/2004 4/2/2008 1288 0 1288 1
022 4/10/2001 2/5/2013 4289 1 4289 1
023 9/13/2001 12/10/2020 6998 0 54 3
024 8/24/2012 2/3/2020 2689 0 0 2
025 5/9/2000 6/8/2000 0 0 0 1
026 4/12/2000 5/12/2000 0 0 0 2
027 6/9/2005 11/24/2008 1234 0 13 3
028 10/23/2008 4/24/2012 1249 0 1249 1
029 5/22/2003 11/17/2008 1976 0 38 3
030 12/13/2000 12/8/2005 1791 0 0 2
031 10/28/2003 8/9/2007 1351 0 0 2
032 3/7/2006 7/12/2007 462 0 462 1
033 3/5/2006 3/22/2013 2544 0 6 3
034 3/5/2000 3/13/2013 4726 1 5 3
035 5/7/2003 3/28/2008 1757 0 0 2
036 8/31/2005 2/5/2009 1224 0 1224 1
037 10/2/2002 3/18/2013 3790 0 94 3
038 7/2/2010 1/8/2019 3082 0 0 2
039 3/27/2002 2/9/2004 654 0 23 3
;
run;
proc print data=have; run;
I think that you need to seriously examine your text describing your variables FUTIME and EVTIME as months. If Futime is months, as stated, then the value of 6998 would be in excess of 583 years. If you derived those values with subtraction of SAS date values then the unit would be days not months.
How do we know, from the values shown, when graft failure occurs? I don't see a statement that clearly states that.
You do not define group=3 at all in terms of the problem. Since this is the most common value that might be a severe short fall in any analysis.
@Merdock wrote:
I need help with setting up my dataset to perform survival analysis with a time-dependent covariate. I read the Therneau et al. paper but I'm still unsure of how to set up the counting process format for my data.
Below is a test dataset similar to what I have.
Data: Liver transplant dataset where some patients are in group 1 (if on immunosuppressive drug A at baseline), others are in group 2 (if on drug B at baseline).
Goal: I want to know how/if the time of first switch from med A to med B impacts graft survival (graft failure is the event of interest). The expectation is that the switch to drug B wouldn't significantly impact graft survival but it's important to show this because drug B would be preferable as it has less side effects, better tolerance profile and is more cost effective than drug A.
GROUP=1, if on drug A; 2 if on drug B, and 3 if they switched from A to B;
CENSOR=1, if event (graft failure) happened, 0 otherwise;
FUTIME = total follow-up time (months) (=CENSDT – transplant date), where CENSDT (not shown here, is either date of event, or date of last follow-up/death)
EVTIME= time of event (months); EVTIME=FUTIME when CENSOR=1, else EVTIME= N/A;
SWITCHDATE (not shown here) =date of first switch from drug A to drug B;
SWITCHTIME=time of first switch from group 1 to group 2 (=SWITCHDATE – transplant date); this will be 0 for those patients who start off on drug B at baseline, and it is FUTIME for those who start off on drug A and never switch (per investigators's request).
data have; input ID$ CENSOR$ FUTIME EVTIME SWITCHTIME GROUP$; datalines; 001 0 1229 . 333 3 002 0 1659 . 343 3 003 0 733 . 509 3 004 0 6998 . 1630 3 005 1 1005 1005 558 3 006 1 4726 4726 147 3 007 0 3790 . 2856 3 008 1 672 672 504 3 009 0 5224 . 2648 3 010 0 4143 . 149 3 011 0 4973 . 500 3 012 1 3626 3626 3624 3 013 0 4296 . 3998 3 014 0 977 . 0 2 015 0 2898 . 331 3 016 0 1382 . 1187 3 017 1 1164 1164 1164 1 018 0 1232 . 336 3 019 1 1599 1599 143 3 020 0 1795 . 111 3 021 0 3171 . 3171 1 022 1 483 483 333 3 023 1 824 824 351 3 024 0 662 . 662 3 025 1 597 597 0 2 026 0 1269 . 0 2 027 0 4120 . 4120 1 028 1 621 621 0 2 029 0 3452 . 3452 1 030 0 1842 . 0 2 ; run;
@ballardw, thanks! I updated my dataset and post. The FUTIME and EVTIME are in months, as I have used the intck function with 'months', not subtraction to calculate them. Graft failure occurs whenever you see CENSOR=1.
I don't understand what you mean by your last statement: "You do not define group=3 at all in terms of the problem".
Please let me know if this is clearer or you need any additional clarifications.
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!
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.