SAS and all other SAS Institute Inc. product or service names are

A Macro to Generate Kaplan-Meier
Plot and Optional Estimates
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective co mpanies.
A Macro to Generate Kaplan-Meier Plot and Optional Estimates
Chia-Ling (Ally) Wu
Applied Biostatistics and Epidemiology, University of Southern California
OUTLINES
OUTPUT
MACRO VARIABLES
Macro
Variable
Macro
Optional Description of Function
Variable
4 _HEADER
Input dataset assumed to ○
_INDATA
be one record per subject.
5 _XLABEL
○
_TIMEVAR
Time variable.
_CENSORVAR
Censoring variable.
6 _YLABEL
○
Analysis stratification for
1
○ _STRATAVAR
Y
KM.
7
○
_ARTITLE
2
○ _REF
Study reference group.
Study stratification
8 _FNMED
_STRATALIS
Y
○
variables in the model.
Select partial data in
9 _FNHR
○
_DATAFL
Y
LIFETEST and PHREG. e.g.
SEX=M.
10 _FNP
Displaying tick marks in X- ○
3 _TINTERVAL
○
axis and at risk counts.
Optional Description of Function
Y
Y
Y
4
○
Figure 1a: Kaplan-Meier Plot of Hypertension
1.0
0.9
6
○
Probability of Hypertension
• Generated survival plot with optional estimates, includes susceptible subject, events number and
total subject number, survival rate with median and it’s 95% CI, hazard ratio estimates with 95% CI
and p-value.
• Supported to customize header, label for X-axis and Y-axis, tick marks for X-axis and add data filter.
• Generated survival plot by PROC LIFETEST and hazard ratio by PROC PHREG.
• Used PROC TEMPLATE with SAS ODS to create output.
0.8
0.7
0.6
0.5
0.4
0.3
The header of the figure.
0.2
The label of X-axis (Time
0.1
interval).
0.0
The label of Y-axis
0
3
6
9
12
(Survival).
5 Time (Years)
○
7 Num ber of Subjects at Risk
○
The label of Number of
Male 2490
1507
1268
1091
930
1
○ Female 1944
subjects at risk.
1163
941
805
671
8
○
The footnote shows
(events : 1848/2490), median : 6.4 (6.0,7.9)
Male
survival median or not.
(events : 1404/1944), median : 6.0 (5.9,7.8)
Female
The footnote shows
9 Hazard ratio : 0.99 (0.92,1.06), p-value : 0.76
○
hazard ratio or not.
10
2
○
○
The footnote shows pvalue for hazard ratio or
not.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective co mpanies.
15
18
21
24
826
696
584
485
567
481
401
330
A Macro to Generate Kaplan-Meier Plot and Optional Estimates
Chia-Ling (Ally) Wu
Applied Biostatistics and Epidemiology, University of Southern California
OUTPUT
THE MACRO
0
○
0 PROC TEMPLATE in 4 lattice layouts. The size of the second lattice was estimated by the number
○
of stratum.
1.0
PROC LIFETEST with ODS dataset to have susceptible subject, events number, total subject
numbers, and survival rate. Used KM method.
0.9
PROC FORMAT with CNTLIN option to capture the label from stratified variable value.
Hazard ratio was calculated by reference group. Default used the last group if not specified.
Specified tick value. The maximum tick was the largest value closed to the multiple of tick value.
7 Specified
4 ○
○
8
○
9
○
6
○
Probability of Hypertension
PROC PHREG with ODS dataset to have hazard ratio estimates. Could optional apply STRATA
option for stratification analysis if needed. Used EXACT method.
-
4
○
Figure 1a: Kaplan-Meier Plot of Hypertension
0.8
0.7
0.6
0.5
0.4
0.3
0.2
header, title of X-axis, title of Y-axis, and title of susceptible subject respectively.
Median survival rate was estimated by PROC LIFETEST. It’s an optional output, default is N.
0.1
Hazard ratio was calculated by PROC PHREG. It’s an optional output, default is N.
0.0
0
10 P-value of hazard ratio was calculated by PROC PHREG. It’s an optional output, default is N.
○
3
6
9
15
18
21
24
5 Time (Years)
○
7
○
Num ber of Subjects at Risk
1
○
12
Male 2490
1507
1268
1091
930
826
696
584
485
Female 1944
1163
941
805
671
567
481
401
330
8
○
Male
Female
2
○
(events : 1848/2490), median : 6.4 (6.0,7.9)
(events : 1404/1944), median : 6.0 (5.9,7.8)
10
○
9 Hazard ratio : 0.99 (0.92,1.06), p-value : 0.76
○
REFERENCES
Berglund (2011), An Overview of Survival Analysis using Complex Sample Data, SAS Global Forum 2011
Kuhfeld and So (2013), Creating and Customizing the Kaplan-Meier Survival Plot in PROC LIFETEST, SAS Global Forum 2013
Gharibvand (2008), A Step-by-Step Guide to Survival Analysis, SAS WUSS Forum 2008
UCLA Institute for Digital Research and Education. http://stats.idre.ucla.edu/sas/seminars/sas-survival/
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective co mpanies.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective co mpanies.