Proc Lifetest 1- Kaplan Meier graph

SAS day 28: Proc Lifetest 1

What are the foundations for FDA or NDA to approve a new medication besides its safety concerns?
Many of us would think about the efficacy of the drug. If we dig in the question a bit further, how do we evaluate the efficacy then?

Survival Analysis is one of the coolest/ most critical methods in Clinical Trials, it is the golden test for medication efficacy: how long will patients survive.

Proc Lifetest is the most widely used model to evaluate the result of survival analysis; it computes and displays the product-limit estimate of the survivor function.

today we will go over the basic Syntax to generate a KM Plot and read the tables.

Key Words:

Patient at Risk:Number of patients still survive at a specified time point

Fail: Number of patients died

Censor/ Event (cnsr):
Censor=1 (Event=0): the patients still survive up to this time point
Event=1(Censor=0) : the patient died
*note: the censoring rule could be extremely perplexing, I just used the simplest example to show the basic concept

Survival time(aval): Most of clinical trial studies use month as a unit, year or days are also legit.

Kaplan Meier:  used to estimate the survival function from Time to Event Data

LogRank Test:  test the null hypothesis that there is no difference between the populations in the probability of an event (here a death) at any time point.
*the most popular statistical test in LifeTest

Data Preparation : ADSL, ADTTE


data adsl;
set adam.adsl;
keep subjid i; 

data adtte;
do i =1 to 100;
aval= rand("Uniform",0, 60);
cnsr= rand("BERNOULLI", 0.88);
if mod(i,2) =0 then paramcd="PFS";
if mod(i,2)^=0 then paramcd="DOR";
if mod(i,2) =0 then trtan="Placebo";
if mod(i,2)^=0 then trtan="Exlir";

data lifetest;
merge adsl(in=a) adtte(in=b);
if a;
by i;

*note: I used Rand function created a dummy dataset.

Sample Data 


Proc Lifetest:

ods trace on;
ods output productlimitestimates=surv(keep=nhl timelist Survival left);
proc lifetest data=lifetest plots=survival(atrisk=0 to 60 by 3) method=km 
              timelist=0 to 60 by 3 ;  
  strata trtan/test=(logrank); 
  time aval*cnsr(1);


Sample Output

Validation Dataset:

As we can see the “Left” column is patient at risk andTrtan” is the strata on the graph
and Timelist is the survival time(aval) point (3 months, 6months), Survival is the probability of overall patient survival until the specified time point.



As the Kaplan-Meier graph demonstrated,  the two treatment group does not show a significant difference, which makes sense, because I used a uniform random number generator. I hope all the drugs can demonstrate such an amazing survival effect! Proc Lifetest is an import application for survival analysis, next time, we will go over the Adjust option, 95% CI, and how to calculate LogRank Test value.


Happy Studying! 💃




  One thought on “Proc Lifetest 1- Kaplan Meier graph

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial
%d bloggers like this: