Programming the statistical procedures from SAS

Comparing 2 Kaplan-Meier estimates

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;
proc phreg data=mydata;
  model t=;
  baseline out=survival loglogs=loglogsurv cif=cif stderr=stderr stdcif=stdcif cumhaz=cumhaz stdcumhaz=stdcumhaz;
  by strata;

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;
   lastcumhaz1=cumhaz1; laststdcumhaz1=stdcumhaz1;
  else if b then do;
   lastcumhaz2=cumhaz2; laststdcumhaz2=stdcumhaz2;
  format pointwise_pvalue 6.4;
  keep t cumhaz1 cumhaz2 stdcumhaz1-stdcumhaz2 pointwise_zvalue pointwise_pvalue;

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

*test at t=5;

data _null_;

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

  if end;

  put pointwise_pvalue=;


Posts: 26

Re: Comparing 2 Kaplan-Meier estimates

Posted in reply to JacobSimonsen

Thank you JacobSimonsen.  I was hoping SAS might have something available, but perhaps not. I currently do something similar to the approach you provided above (which is greatly appreciated, by the way) but a little different.  I get the 5-year survival estimates and corresponding standard error, based on the log-log transformation, for each group from the outsurv option in PROC LIFETEST.  Then conduct a simple z-test or build a confidence interval for the difference assuming a normal distribution.

I am replicating some results conducted by a previous statistician using the same data set.  Everything matches nicely but the CI I obtain is slightly different.  Given this, I started wondering if SAS had something more exact than the z-score method I am using.  I will try yours when I have time to see how well it matches.

Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation