I have the following dataset:
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
;
run;
proc print data=have; run;
How can I get this dataset into a counting process format for time-dependent covariate survival analysis? The time-dependent covariate would be “switch” from table below. The IDs whose FUTIME NE SWITCHTIME (group=3) are the ones who switched from group 1 to group 2 at that respective SWITCHTIME so they would get switch=1. I also want everybody who had SWITCHTIME=0 to have switch=1.
I’ve already done this in R but I want to double check my results in SAS and also learn how to convert this dataset using data steps, as opposed to programming statement.
So basically I want my final dataset to look like this:
Thanks!
Where do the values of Tstart, Tstop and status come from??? Your want also shows two values of Id=006. Why?
If you have accurately described how Switch is to be set then maybe:
data switch; set have; switch= ( (FUTIME NE SWITCHTIME) or (SWITCHTIME=0) ); run;
But you appear to be missing a number of details.
Where do the values of Tstart, Tstop and status come from??? Your want also shows two values of Id=006. Why?
If you have accurately described how Switch is to be set then maybe:
data switch; set have; switch= ( (FUTIME NE SWITCHTIME) or (SWITCHTIME=0) ); run;
But you appear to be missing a number of details.
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 16. 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.