Hi SAS communities, I am performing a survival analysis where the event of interest is outpatient prescription and competing risks include death, admission to hospital, and admission to long-term care. I have been trying to write a code to find the follow-up time for each individual in the study; however, some individuals experience more than one event, and I want to calculate time from the earliest event experienced, whether it be the event of interest or a competing risk. This is a simplified version of the dataset: ID index_date prescription service_date death_date hosp_admdate LTC_admdate death hosp LTC censor censdate 001 09Sep2019 0 . 16Dec2019 . . 1 0 0 002 01Feb2019 1 19Jun2019 06Jul2019 08May2019 . 1 1 0 003 06Dec2020 0 . . . . 0 0 0 004 01Mar2020 1 05Mar2020 . . 09Feb2020 0 0 1 005 02Dec2018 0 09Feb2019 . 01Mar2019 . 0 1 0 Service_date: date of prescription. End of study date: 10Mar2020. I found a code online which creates a censor variable and censdate based on the event, I am just not sure how to modify this code so that it captures the multiple competing risks and takes only the earliest event as the censdate.
... View more