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

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:

Merdock_0-1679076261476.png

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

2 REPLIES 2
ballardw
Super User

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.

Merdock
Quartz | Level 8
Thanks so much and my apologies for the delayed response, a lot going on the past month!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 693 views
  • 1 like
  • 2 in conversation