Hi all,

I have a dataset I am analysing using survival analyses, with multiple records per patient. I am looking to split up my survival analyses by survival time (e.g. 0-3 years and 3 years+), but I am having trouble working out how to do this.

I wrote the following code before my dataset was split into multiple records per patient, but this isn't working anymore with multiple records per patient, as each patient with multiple records has the same exit point now;

gen timezerothree=dodreg-dateofdiag
*replace timezerothree=lastfu_newformat-dateofdiag if dodreg==.
replace timezerothree=(min(lastfu_newformat,td(31dec2017))-dateofdiag) if dodreg==.
replace timezerothree=timezerothree/365.25
replace timezerothree=3 if timezerothree>3
replace timezerothree=0 if timezerothree==.

gen bcdeathstatus03=1 if timezerothree<3 & timezerothree>0 & bcdeathnew==1
replace bcdeathstatus03=0 if bcdeathstatus03==. & bcdeathnew!=.

replace timezerothree=. if bcdeathnew==.

stset timezerothree, fail(bcdeathstatus03==1) id(patientid)
----------------------------------------------------------​​​​​​​-----------------------------​​​​​​​-----------------------------​​​​​​​-----------------------------​​​​​​​-----------------------------​​​​​​​-----------------------------​​​​​​​-----------------------------​​​​​​​------------------------

Can someone please help me?