options nofmterr;
data lymphoma;
set biom505.lymphoma;
run;
/*********************
Plot Kaplan-Meier Survival curves of lymphoma patients by
stage of tumor.
See Armitage et al. 2002, Table 17.3.
McKelvey et al., 1976.
***********************/
/*********
Two variables must be defined to
give each patient both (1) length of
follow-up and (2) fate at exit. In
this example, these variables are
called time and fate respectively:
time (in days)
fate =0 means alive
fate =1 meas dead
fate = 0 to mean that the patient is censored at exit
fate = 1 to mean that subject suffered the event of interest at exit.
*********************/
/***
proc lifetest plots Kaplan-Meier survival curves.
strata stage specifies that separate curves will
be generated for each value of stage. The yaxis
title is Probability of Survival.
****/
ods graphics on;
ODS OUTPUT CensoredSummary =_censorsum Means =_mean Quartiles =_quartiles;
proc lifetest data =lymphoma plot=(s (cl) all) censoredsymbol=none outsurv=surv;
time time*fate(0);
strata stage;
run;
/**
The accuracy of the survival curve gets less as we move
towards the right, as it is based on fewer and fewer patients
**/
/* Kaplan-Meier survival curves by stage with 95% CIs*/
proc lifetest data =lymphoma plot=(s (cl) all) censoredsymbol=none outsurv=surv;
by stage;
time time*fate(0);
run;
/*
* Perform log-rank test to compare stage 3 and 4 survival
*/
ODS OUTPUT CensoredSummary =_censorsum Means =_mean Quartiles =_quartiles;
proc lifetest data =lymphoma plot=(s (cl) all) censoredsymbol=none outsurv=surv;
time time*fate(0);
strata stage/ test=(all);
run;
/****
* Perform proportional hazards regression analysis of
* lymphoma patients by stage of tumor.
******/
/***The probability density function, f(t)***/
proc univariate data = lymphoma;
var time;
histogram time / kernel;
run;
/**The cumulative distribution function, F(T)***/
proc univariate data = lymphoma;
var time;
cdfplot time;
run;
/**The Survival function, S(t)***/
proc lifetest data =lymphoma plots=survival(atrisk);
time time*fate(0);
run;
/***The hazard function, h(t)***/
proc lifetest data=lymphoma plots=hazard;
time time*fate(0);
run;
/********The cumulative hazard function H(t)***/
ods output ProductLimitEstimates = ple;
proc lifetest data=lymphoma nelson outs=outlymph;
time time*fate(0);
run;
proc sgplot data = ple;
series x = time y = CumHaz;
run;
ods graphics on;
proc phreg data=lymphoma plots(overlay)=survival;
class stage (ref="3");
model time*fate(0)=stage /rl;
assess ph / resample ;
run;
ods graphics off;