# Surviving three years after surgery

I would like to calculate the probability of surviving three years after surgery. My dataset has four columns:

• date of surgery (surgery_date)
• date of death (death_date)
• years to death (survival)
• censored status (death) (1 = patient died, 2 = patient is alive)

Data is structured as follows:

# A tibble: 370 x 4
surgery_date death_date survival death
<date>     <date>    <dbl> <dbl>
1   2008-03-26 2014-03-21 5.984942     1
2   2008-04-17         NA       NA     2
3   2008-05-15         NA       NA     2
4   2008-05-15 2014-12-27 6.617385     1
5   2008-05-16         NA       NA     2
6   2008-05-23         NA       NA     2
7   2008-06-11         NA       NA     2
8   2008-06-16         NA       NA     2
9   2008-06-18         NA       NA     2
10   2008-06-30         NA       NA     2
# ... with 360 more rows


I go through various tutorials on the Web where authors assume that we have two variables: time_to_event variable with exact time to the end of study for each patient and status variable with censoring status (censored vs. dead). However, in my settings I only have survival times for patients who died.

The question is how to use Kaplan-Meier to compute the probability that a patient will survive the first three years after surgery?

• You will need to make some assumption about when data collection ended. Anything between the last date in your dataset and today (or: whenever you got your data) would be defensible. Try running the analysis with multiple reasonable endpoints and see whether your results are strongly affected or not. Dec 26, 2017 at 8:39
• @StephanKolassa of course we can't tell without seeing all the data, but if the latest deaths are in 2014, and the earliest surgeries are in 2008, then it would make a lot of a difference whether the study ended in 2014 or today (2017). Anyway, your suggestion of studying the sensitivity of results to the endpoint makes sense. I would still try to get the end date from the study authors, but your idea is interesting too (+1). Dec 26, 2017 at 23:02

With these data you can't. You need to know the end date of the study (presumably not earlier than the end of 2014, since you have a death at the end of December 2014). Let's assume that end_date = "2014-12-31". Then you need to create a variable which holds the survival time for people who died during the analysis, and the difference between end_date and surgery_date for the others.

 library(magrittr)
library(dplyr)
library(lubridate)

end_date = "2014-12-31"
df %<>% mutate(survival = ifelse(death == 1, survival, (end_date %--% surgery_date)/dyears(1)))


At this point you can use your package of preference to compute the Kaplan-Meier estimator, and then just evaluate it at 3 years. I don't think this analysis will be extremely informative though - I don't know which kind of surgery you're interested in, but I would expect at least age to be highly correlated with the survival time. I'm not sure how much you can learn from a survival analysis which neglects the role of any predictor.

NOTE of course all this relies on the assumption that you know the end date of the study. If you don't, you can't just guess it. You need to get in touch with the study's authors and get it, otherwise you can't proceed.