Event definition for survival analysis

Dear all,

I am performing an observational study which includes several thousand patients. I plan to run a survival analysis with the competing risk. My planned outcome is reoperation. My current data frame is as follows.


As you see, there is no event column which is a requirement for survival analysis. I am wondering whether I could use several codes (e.g. R) to create a column which includes first operation, second operation and death. Or I have to add this column to each observation manually.

Thank you for your time and Happy New Year!


This will require some thought, and I recommend that you study the vignettes that come with the R survival package of Terry Therneau, along with the Therneau and Grambsch book Extending the Cox Model. A key issue is whether your type of data are appropriate for a competing risk analysis. Competing risk models are used primarily when all the events are terminating events. For example if you have time to death as the outcome variable but different causes of death, and you want to make a statement about cardiovascular death even though it can be interrupted by cancer death.

Thank you so much, Frank!

I am trying to use dplyr::mutate and case_when to create a new column which includes three different events. I will paste my code here if success.

Data pipe
group_by(ID) pipe
mutate(rank=min_rank(Time)) pipe
mutate(event=case_when(Inter==“Death”~2, rank==1~0,rank==2~1))

I think my data are appropriate for a competing risk analysis because the age of many of the included patients are more than 60. Thus, patients may die rather than receive the second operation. My question structure is as follows.

I will carefully read the materials you mentioned.

Thank you so much and wish you have a great weekend!