Converter tool

Kaplan-Meier Survival Curves from a CSV

Estimate survival curves from time and event columns, with Greenwood confidence intervals, median survival, a log-rank test across groups, a number-at-risk table and a step-curve SVG you can download.

One row per subject

1. Your data

Or paste the table

Kaplan-Meier Survival Curves from a CSV

Operator: Abdulla Al Fahad. How tools are built and checked

A 36-month follow-up of 180 patients on three arms gives a median survival of 17.6 months on standard care (95% interval 9.1 to 23.6) and 26.8 on Drug A (19.6 to not reached), while Drug B's curve never falls to 0.5 within follow-up. A log-rank test across the three arms gives chi-square 12.79 on 2 degrees of freedom, p = 0.0017.

The page needs a follow-up time, an event flag and optionally a group. It draws the step curves with optional confidence bands and censor marks, lists how many subjects are still at risk at times you choose, and exports the life table. For the share of a customer cohort still active each month, where everyone has the same calendar window, Cohort Retention Analysis is the simpler tool; Kaplan-Meier is for rows with unequal follow-up and censoring.

Key features

  • Kaplan-Meier product-limit estimate per group with Greenwood standard errors
  • Log-log, log or plain 95% confidence intervals, optionally drawn as bands
  • Median survival with its interval, shown as not reached when the curve stays above 0.5
  • Log-rank test across all groups, pairwise log-rank tests with Holm adjustment, and an approximate hazard ratio for two groups
  • Number at risk at chosen times, a full life table, and a step-curve SVG with the legend inside the file

How a table of times and events becomes a survival curve, and what censoring changes

One row per subject: a non-negative follow-up time, an event column and optionally a group. You choose which value of the event column means the event happened (1, true, dead, churned and so on); every other value is censored, meaning the subject was still event-free when last observed. The time unit is only a label for the axis.

Up to 12 groups and 200,000 rows are handled. Rows with a blank or non-numeric time or a blank event are left out and counted, as are rows with a negative time. A time of 0 is allowed, and an event at time 0 lowers the curve immediately. If no row has the event, the page stops, because every observation is censored and there is nothing to estimate.

How it works

At each distinct event time the survival estimate is multiplied by (1 - events / at risk), where those at risk are subjects whose time is at or after that point. Censored subjects stay in the risk set until their own time and then leave, which is how partial follow-up still counts. The Greenwood variance adds events / (at risk x (at risk - events)) at each step. The log-log interval, the default, raises S to the power of exp(plus or minus 1.96 x se / |ln S|), where se is the square root of the Greenwood sum, and so always stays between 0 and 1; the log interval multiplies S by exp(plus or minus 1.96 x se) and the plain one adds and subtracts 1.96 x S x se. The median is the first time the curve is at or below 0.5, with the interval taken from the first times the lower and upper bands reach 0.5.

The log-rank test pools every event time. At each one it compares each group's observed events with the number expected if the groups shared one hazard, d x n_group / n, and builds the hypergeometric variance and covariances. The statistic is the quadratic form of the observed-minus-expected vector over all but one group with the inverse variance matrix, referred to chi-square with one fewer degrees of freedom than groups. A group with no expected events (nobody at risk when any event happened) carries no information and is left out of the statistic, with a note. Pairwise tests repeat that for each pair of groups, with Holm's step-down adjustment. For two groups, the hazard ratio shown is exp((O1 - E1) / V1), a one-step approximation from the same statistics, not a Cox model.

Common use cases

  • A trial report where Drug B versus standard care is the pre-planned comparison (Holm-adjusted p = 0.0013) and the Drug A comparisons are exploratory.
  • Customer lifetime in months from signup to cancellation, with active customers censored at the export date.
  • Time to first failure of 40 pumps in two designs, where 12 are still running at the end of the test.

How to use this tool

  1. Open a table with a follow-up time and an event column, or press Load example for the 180 sample patients.
  2. Choose the time, event and group columns, and the value of the event column that means the event happened.
  3. Pick the interval type and switch on bands or censor marks if wanted.
  4. Read the medians, the log-rank test, the number at risk and the life table.

Example

Excerpt of the example (180 patients, three arms)

patient,arm,months,status
P143,Drug B,13.1,1
P099,Drug A,27.3,0
P179,Drug B,8.3,0
P010,Standard care,29.2,1
...

Summary and tests

Standard care: 60 patients, 37 events, median 17.6 (9.1 to 23.6)
Drug A: 60 patients, 27 events, median 26.8 (19.6 to not reached)
Drug B: 60 patients, 18 events, median not reached (25.5 to not reached)
Log-rank chi-square 12.79, 2 df, p = 0.0017
Drug B vs Standard care p = 0.0004 (Holm 0.0013); Drug A vs Standard care p = 0.053 (Holm 0.106); Drug A vs Drug B p = 0.110

Tips for best results

  • Make the event column explicit when exporting. A column called status can mean 1 = dead or 1 = alive; the page asks which value is the event for exactly that reason.
  • Read the number-at-risk row under the curve: a plateau at the right with 3 subjects left is a few people, not a stable survival rate.
  • Use the log-log interval unless you need to match another package's default. It never leaves the 0 to 1 range, which the plain interval can do near the ends.

Common pitfalls

Treating censored subjects as events, or dropping them, understates survival; treating them as event-free to the end of the study overstates it. Censored subjects belong in the file with the event flag set to the not-event value.

The log-rank test assumes proportional hazards. If the curves cross, its p-value can miss a real difference, so look at the plot as well.

Medians shown as not reached are a statement about follow-up, not about infinite survival. Quote the survival at a fixed time instead.

Common errors and how to fix them

No row has the event, so every observation is censored
The chosen value of the event column never appears. Check the dropdown: the event may be 1 where you chose 0, or the column may use a label such as Y.

Best practices

  • When a median is not reached for some arms, compare the arms at a fixed time read from the life table, for example survival at 24 months with its interval, because a median that does not exist cannot be compared.

Censoring is not missing data

A censored subject is one you know something about: they were event-free for at least as long as you watched them. Dropping them throws that information away, and treating their last time as an event invents one. The product-limit method uses them correctly by keeping them in the risk set until their censoring time.

That is also why the event flag matters more than the time. In the example, 98 of the 180 patients are censored, at different times because patients were followed for different lengths, and the curves are still estimated from every one of them.

Reading the number-at-risk table

The table counts subjects whose time is at or beyond each chosen time, so it falls with both events and censoring. When it gets small, the drop of a single event moves the curve a long way and the confidence band widens, which is why the right-hand end of a survival curve deserves less trust than the left.

Choose times that match your reporting, such as 6, 12 and 24 months, and read survival from the life table at those times rather than from the plot.

Frequently asked questions

How are tied event times handled?

Subjects with the same time are processed together: all events at that time are removed in one step using the number at risk just before it, and censored subjects at that time still count as at risk for the events. This is the standard Kaplan-Meier convention.

Why is the interval for the median sometimes open on one side?

The interval ends where the lower or upper confidence band first reaches 0.5. If a band never gets there within follow-up, that end is not reached. A median of 23 with an interval of 13 to not reached, for instance, means the upper band stayed above 0.5.

Can I adjust for age or other covariates?

No. Kaplan-Meier compares groups without adjustment. To control for covariates you need a Cox proportional hazards model, which this page does not fit.