BookmarkSubscribeRSS Feed
mostater
Obsidian | Level 7

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.

2 REPLIES 2
JacobSimonsen
Barite | Level 11

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;

mostater
Obsidian | Level 7

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2469 views
  • 4 likes
  • 2 in conversation