Home > Output

#
Chapter 11: Survival analysis using SAS

###
Figure 11.1 *Kaplan–Meier curve*

###
Figure 11.2 *Kaplan–Meier curve with logrank test*

###
Figure 11.4 *Output for Kaplan–Meier estimates of survival and logrank test*

###
Figure 11.1, 11.2 and 11.4 Code

Click here to show code as text
/* Create a library called "source". This means that when you process datasets
that have been imported into sas you can Use the word source instead of
having to type the path to the folder holding the SAS datasets. SAS will
only be able to read data from that folder not accidentally change the data. */
libname source "C:\Projects\Books\Presenting\data\sasData" access = readonly;
/* These is a user defined format that can be used on any variable.
They last until you restart SAS. */
proc format;
/* Display numeric values with words. The number before the ) will cause
these to display in logical order. */
value diabetes
0 = "Normal"
1 = "Diabetic"
; /* The ; goes after all the categories. */
run;
proc lifetest data = source.pvd
(rename = (diabetes = Dx)) /* rename diabetes to Dx for plotting */
/* Include a K-M plot with the p-value test value an the number of
people at risk at 0 20 40 60 80 100 months */
plots=Survival(test atrisk = 0 to 100 by 20 )
outsurv = work.survivalRate;
; /* end of the lifetest statement */
format dx diabetes.; /* use the label for plotting */
/* Time until event/censoring is in the months variable. Censoring vs
event is in the outcome variable and 0 means censoring */
time months*outcome(0);
strata Dx; /* Compare levels of the Dx variable */
run;
/* Create a format to show months. Values from 10 to 11 will display as 12
and values 45 to 56 will display as 60. These ranges cover the last event
dates before 12 and 60 months. */
proc format;
value rounded
10 - 12 = "12"
45 - 56 = "60"
; /* The ; goes after all the categories. */
run;
/* After looking at the survivalRate dataset I am choosing the last data
from an event before 12 and 60 months. */
proc print data = survivalRate noobs label round;
/* Selecting the 4 values of interest */
where (dx = 1 and (round(months,1) = 10 or round(months,1) = 45))
or (dx = 0 and (round(months,1) = 11 or round(months,1) = 56));
format months rounded.; /* Apply the tricky format from above */
label Dx = "Dx"; /* Display the Dx with the label Dx */
label months = "Months"; /* Display months capitalized */
id dx months; /* Show the dx and month as the id variables */
var survival sdf_lcl sdf_ucl; /* Show surival funciton with confidence limits*/
run;

###
Figure 11.5 *Output for Cox regression with one predictor available*

###
Figure 11.5 Code

Click here to show code as text
proc phreg data = source.pvd;
/* Time until event/censoring is in the months variable. Censoring vs
event is in the outcome variable and 0 means censoring. Predict events
with the diabetes variable. */
model months*outcome(0) = diabetes;
hazardratio diabetes; /* request the confidence limtis on the hazard */
run;

###
Figure 11.6 *Output for Cox regression with more than one predictor variable*

###
Box 11.8 *Presenting Cox regression analysis*

###
Figure 11.6 and Box 11.8

Click here to show code as text
proc phreg data = source.pvd;
/* Use Effron instead of Breslow method to deal with ties in the prediction */
model months*outcome(0) = diabetes age70 / ties = effron;
hazardratio diabetes;
hazardratio age70;
run;
proc phreg data = source.pvd;
/* Use Effron instead of Breslow method to deal with ties in the prediction */
model months*outcome(0) = age70 / ties = effron;
hazardratio age70;
run;