Contributor
Posts: 26

# Comparing 2 Kaplan-Meier estimates

Is there a SAS option to compare Kaplan-Meier estimates?  I have a strata variable defined at 2 levels and would like to compare the KM survival estimates at a specific time point (5 years, in my case), e.g. strata level 1 KM 5-year estimate vs. strata level 2 KM 5-year estimate.  Is it possible to do this in SAS PROC LIFETEST or elsewhere?  A p-value or, even better, the confidence interval of the difference would be great.

Super Contributor
Posts: 301

## Re: Comparing 2 Kaplan-Meier estimates

In case that you have no censoring, then the easiest way is to create a binary variale indicating whether or not the persone has event before the time of interest (t=5 in your case). Then make a logistic regression to see if there is association between this binary variable and your strata variable.

If there is censoring then it becomes more complicated. I dont think there is any procedure that can do it for you, so you have to construct the test yourself. I suggest to test the cumulated incidence functions eqaul at the t=5. This is equivalent to test equal KM-curves, but has better asymptotic behaviour. PHREG can give you the cumulated incidencefunctions as well as the standard-errors.

data mydata;
do strata=1 to 2;
do i=1 to 10000;
t=-10*log(ranuni(-1))/exp(0.0*(gruppe=2));
output;
end;
end;
run;
proc phreg data=mydata;
model t=;
baseline out=survival loglogs=loglogsurv cif=cif stderr=stderr stdcif=stdcif cumhaz=cumhaz stdcumhaz=stdcumhaz;
by strata;
run;

data test;
set survival(in=a where=(strata=1) rename=(cumhaz=cumhaz1 stdcumhaz=stdcumhaz1))
survival(in=b where=(strata=2) rename=(cumhaz=cumhaz2 stdcumhaz=stdcumhaz2));
by t;
retain laststdcumhaz1-laststdcumhaz2 lastcumhaz1 lastcumhaz2;
if a then do;
stdcumhaz2=laststdcumhaz2;cumhaz2=lastcumhaz2;
lastcumhaz1=cumhaz1; laststdcumhaz1=stdcumhaz1;
end;
else if b then do;
stdcumhaz1=laststdcumhaz1;cumhaz1=lastcumhaz1;
lastcumhaz2=cumhaz2; laststdcumhaz2=stdcumhaz2;
end;
pointwise_zvalue=(cumhaz1-cumhaz2)/sqrt(stdcumhaz1**2+stdcumhaz2**2);
format pointwise_pvalue 6.4;
pointwise_pvalue=2*sdf('normal',abs(pointwise_zvalue));
keep t cumhaz1 cumhaz2 stdcumhaz1-stdcumhaz2 pointwise_zvalue pointwise_pvalue;
run;

symbol i=join v=none;
proc gplot data=test;
plot pointwise_pvalue*t;
run;

*test at t=5;

data _null_;

set test(where=(t<5)) end=end;

if end;

put pointwise_pvalue=;

run;

Contributor
Posts: 26