Why survival data needs Kaplan-Meier
Time-to-event data, whether time to relapse, to churn or to machine failure, has one awkward feature: not everyone has the event before observation stops. A patient who leaves the study at month 6 without a relapse is censored. You know they were event-free up to month 6, but not what happened after. Dropping censored patients wastes that information and biases the result. Counting them as event-free for the whole study overstates survival. The Kaplan-Meier estimator uses each patient exactly as long as they were observed: they count in the risk set until they are censored, and then they leave it.
Worked example: time to relapse, 18 patients, 24 months
Columns A to C are the input, one row per month with an event or a censoring. Column D tracks the risk set, columns E and F the survival estimate. Rows 14 to 18 are the summary.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Month | Events d | Censored c | At risk n | 1 − d ÷ n | S(t) |
| 2 | 0 | 0 | 0 | 18 | 100.0% | |
| 3 | 2 | 1 | 0 | 18 | 0.9444 | 94.4% |
| 4 | 3 | 1 | 1 | 17 | 0.9412 | 88.9% |
| 5 | 5 | 2 | 0 | 15 | 0.8667 | 77.0% |
| 6 | 6 | 0 | 1 | 13 | 1.0000 | 77.0% |
| 7 | 8 | 1 | 0 | 12 | 0.9167 | 70.6% |
| 8 | 10 | 1 | 1 | 11 | 0.9091 | 64.2% |
| 9 | 12 | 1 | 0 | 9 | 0.8889 | 57.1% |
| 10 | 15 | 0 | 2 | 8 | 1.0000 | 57.1% |
| 11 | 18 | 1 | 0 | 6 | 0.8333 | 47.6% |
| 12 | 24 | 0 | 5 | 5 | 1.0000 | 47.6% |
| 13 | ||||||
| 14 | Median survival: first month with S(t) ≤ 50% | 18 | ||||
| 15 | S(t) at 12 months | 57.1% | ||||
| 16 | Events in total | 8 | ||||
| 17 | Censored in total | 10 | ||||
| 18 | Naive share event-free (ignores censoring) | 55.6% | ||||
- D4
=D3-B3-C3Risk set shrinks by events and censored - E5
=1-B5/D5Conditional survival in month 5 - F5
=F4*E5Cumulative survival S(t) - F14
=MINIFS(A3:A12,F3:F12,"<=0.5")Median survival time
Fictional data for learning. Educational only, not medical advice.
Step 1: one row per distinct time
Sort the raw data by time and list each distinct month that has an event or a censoring. Count both per month from the raw rows with =COUNTIFS(time,A3,status,1) for events and =COUNTIFS(time,A3,status,0) for censored patients, with status 1 = event and 0 = censored. Tied times must be grouped in one row, two relapses in month 5 are one row with d = 2. Add a row for month 0 with S(t) = 100%, so the curve starts at the top.
Step 2: the number at risk
Everyone is at risk at the start, here 18 patients, which =SUM(B3:C12) confirms: every patient appears exactly once, as an event or as censored. After that, the risk set shrinks by the events and the censored patients of the previous row: n = previous n − previous d − previous c. In month 5 the risk set is 15, because one patient relapsed in month 2, one in month 3 and one was censored in month 3. By convention, a patient censored in the same month as an event still counts at risk for that event.
Step 3: conditional and cumulative survival
The conditional survival of a row is the share of the risk set that gets through that month without the event: =1-B5/D5, 1 − 2 ÷ 15 = 0.8667 in month 5. The cumulative survival S(t) multiplies all conditional survivals so far: =F4*E5, 88.9% × 0.8667 = 77.0%. Months with only censored patients have d = 0, so S(t) stays flat and only the risk set shrinks. That is the whole difference from a naive percentage: censoring changes the denominator, never the numerator.
Step 4: median survival and survival at a fixed time
The median survival time is the first time at which S(t) is 50% or lower: =MINIFS(A3:A12,F3:F12,"<=0.5") returns month 18, where S(t) drops from 57.1% to 47.6%. If the curve never reaches 50%, the median is "not reached" and MINIFS returns 0, so check for that. Survival at a fixed time, such as 12 months, is the S(t) of the last row at or before that time: =INDEX(F2:F12,MATCH(12,A2:A12,1)) = 57.1%. The approximate MATCH also works for a month that has no row of its own.
Step 5: draw the step chart
A Kaplan-Meier curve is a step function: flat between events and dropping straight down at each event. A line chart draws diagonals instead. To get real steps in Excel, build a small plot table that repeats every event time twice, once with the old S(t) and once with the new one (0 → 100%, 2 → 100%, 2 → 94.4%, 3 → 94.4%, 3 → 88.9% and so on), and plot it as an XY scatter with straight lines. Mark censored times with small tick marks as a second series, set the y-axis from 0 to 1 and label the axes "Months" and "Survival probability". Many journals also show the number at risk under the x-axis.
Confidence intervals and comparing groups
The estimate becomes uncertain as the risk set shrinks: the last step here rests on only six patients. Greenwood's formula gives the standard error of S(t), S(t) × √Σ d ÷ (n × (n − d)), and a 95% interval of roughly S(t) ± 1.96 × SE, or a log-log version that stays between 0 and 1. To compare two arms, build one table per arm and plot both curves. Whether they differ significantly is a log-rank test, which compares observed and expected events at each time and is easier in a statistics package. For the arm comparison at one time point, the relative risk and odds ratio guide shows the 2 × 2 measures, and the sensitivity and specificity guide covers diagnostic tests.
Common mistakes
- Dropping censored patients. Leaving them out shrinks the risk set from the start and makes survival look worse than it is. They count at risk until the time they are censored.
- Treating censored patients as survivors to the end. That is the naive 55.6% in the example, too high, because nobody knows what happened to them after they left.
- Forgetting the censored patients in the risk set. n must fall by d and c of the previous row. Subtracting only events keeps people at risk who are no longer observed.
- One row per patient with tied times. Two events in the same month belong in one row with d = 2, otherwise the at-risk count of the second row is wrong.
- Drawing a line chart. Diagonal lines between points suggest a gradual decline. Use an XY scatter with each time repeated, so the curve drops in steps.
- Over-reading the tail. The right end of the curve rests on a handful of patients. Show the number at risk and the confidence interval before drawing conclusions from it.
Frequently asked questions
How do I calculate Kaplan-Meier survival in Excel?
For each time with an event, compute the number at risk n, the events d and the conditional survival 1 − d ÷ n, then multiply: S(t) = S(previous) × (1 − d ÷ n). The risk set falls by the previous row's events and censored cases.
How do I plot a Kaplan-Meier curve in Excel?
Build a plot table that repeats each event time twice, once with the previous S(t) and once with the new one, and insert an XY scatter with straight lines. That draws horizontal steps with vertical drops. Add censored times as markers in a second series.
What does censored mean in survival analysis?
A censored observation is one where the event had not happened by the last time the person was observed, because the study ended or they were lost to follow-up. Their time counts up to that point, but not after.
How is the median survival time read from a Kaplan-Meier curve?
It is the first time at which the survival estimate falls to 50% or below. In Excel, MINIFS(time_range, survival_range, "<=0.5") returns it. If the curve stays above 50%, the median is not reached.