Download presentation
Presentation is loading. Please wait.
Published byTülay Bozkurt Modified over 6 years ago
1
AA-08: Kaplan-Meier Survival Plotting Macro %NEWSURV
Jeffrey Meyers Mayo Clinic, Rochester, Minnesota The pharmaceutical and clinical oncology research fields rely heavily on time-to-event endpoints to assess the efficacy of treatments. One of the best graphical displays of time-to-event analysis is the Kaplan-Meier curve, which is simple to make but difficult to customize within SAS. My office has relied upon other software such as Microsoft Excel in order to make their customized Kaplan-Meier curves. This is incredibly inefficient as it required running the analysis in one program, exporting to another program, and manually making the graph, often with the need to create text boxes on top of the graph to show statistics. If the data was updated then the process would need to be repeated almost in its entirety. This has changed with the advent of the SAS SG graphics engine and the Graph Template Language which has improved the appearance and customizability of SAS graphics. The macro NEWSURV takes advantage of the Graph Template language to list the analyzed statistics directly into a Kaplan-Meier plot programmatically, eliminating the need for backend effort. This presentation is an overview of the features of the macro NEWSURV and a walkthrough of the main points of how the macro creates the Kaplan-Meier curves. Give introduction here: Pharmaceutical and clinical trial research heavily dependent on time-to-event endpoints A need to consolidate tables and figures for journal publications and posters. Need for efficiency Relying on other programs tedious Graph Template Language (GTL) adds customizability Exploring led to the ability to add statistics into plots programmatically Repeated programming and positive feedback led to the urge to build a macro
2
Contents Macro Overview What the macro does How the macro does it
Computed Statistics Designing the Plot Designing the Lattice Statistical Report Table Conclusion The first section of the presentation will cover a quick overview of what the output from the macro looks like. I will then lead you through the main features of the macro to give a taste of what it is capable of creating. The description of how the macro works will focus on three key areas: How the statistics are computed and saved, how the template for the graph is designed, and how the graph creates a lattice of plots. Then I will briefly touch on a separate statistical report table that can be generated from the macro outside of the plot.
3
Macro Overview (Plot) Simple to customize. Can be customized as much as user wants Calculated statistics Patients-at-risk numbers Output formats Scalable vector graphics Lattice
4
Macro Overview (Statistical Report)
General Statistical Report Table Example Event/Total Median (95% CI)† Hazard Ratio (95% CI)‡ Survival Estimates (95% CI)† P-value SASHELP.BMT Data set with no Class Variable All Patients 83/137 1.3 ( ) 1 Years: ( ) 2 Years: ( ) This is the footnote for this model SASHELP.BMT Data set with Class Variable Group 0.0010$ ALL 24/38 1.1 (0.5-NE) Ref 1 Years: ( ) 2 Years: ( ) AML-High Risk 34/45 0.5 ( ) 1.47 ( ) 1 Years: ( ) 2 Years: ( ) AML-Low Risk 25/54 6.0 (1.9-NE) 0.56 ( ) 1 Years: ( ) 2 Years: ( ) †Kaplan-Meier method; ‡Cox model; $Score test; This also allows an overall footnote Outputs into RTF, HTML or PDF Customizable columns, text, footnotes, and titles Automatically generated with plot
5
Sample Dataset SASHELP.BMT GROUP – categorical
Acute Lymphoblastic Leukemia (ALL) Acute Myeloid Leukemia (AML) High Risk and Low Risk T – time from transplant STATUS – survival status 0=Alive 1=Dead Three Class levels with group variable acute lymphocytic leukemia acute myeloid leukemia high risk acute myeloid leukemia low risk Time variable Status variable Only available in SAS9.3 or later
6
Key Features/Parameters
Line and Axes Transformations Plot Summary Table Options Dataset Transformations Only Required Variables YTYPE, YMIN, YMAX & YINCREMENT %NEWSURV(…, CLASSORDER=3 1 2, CLASSREF=AML-Low Risk, CLASSVALALIGN=left, DISPLAY=legend total event hr pval timelist, PLOTPVAL=logrank, TIMELIST=0.5 1, TIMEDX=Years); LANDMARK CLASSREF TIMELIST & TIMEDX %NEWSURV(…, PATTERN=2 3 4, COLOR=blue red green, LINESIZE=3pt, SYMBOLSIZE=10pt, YTYPE=ppt, YMIN=0.25,YMAX=1,YINCREMENT=0.05, XMIN=0,XMAX=7.5,XINCREMENT=0.5, YLABEL=Proportion Alive, XLABEL=Disease-Free Survival Time (Years)); CLASSORDER CLASSVALALIGN COLOR & PATTERN CLASS & WHERE DISPLAY %NEWSURV( DATA=sashelp.bmt, TIME=T, CENS=status, CEN_VL=0); %NEWSURV(…, CLASS=group, WHERE=group in('ALL' 'AML-High Risk'), XDIVISOR=30.44, LANDMARK=3.0); PLOTPVAL Walk through each category of options Make sure to describe what landmark analyses are Pause briefly on each macro call example XDIVISOR XMIN, XMAX, &XINCREMENT DATA, TIME, CENS, CEN_VL
7
Patients-at-Risk Table Variations
%newsurv(…, RISKLABELLOCATION=left, RISKLOCATION=bottom, RISKLIST=0 to 7.5 by 0.5, RISKCOLOR=1, PARHEADER=Patients-at-Risk); Show the different variations of the patients-at-risk table Mention label locations Mention coloring the numbers Mention header Show macro call example RISKLABELLOCATION RISKLOCATION RISKCOLOR PARHEADER
8
Lattice of Plots %NEWSURV(TIME=T, CENS=status,CEN_VL=0, SREVERSE=1|0,
NMODELS=2,ROWS=1,COLUMNS=2, ORDER=rowmajor, TITLE=%str(A%))|%str(B%)), FOOTNOTE=Footnote1|Footnote2, OVTITLE=Title for entire image, OVFOOTNOTE=Footnote for entire image,…); TITLE OVTITLE SREVERSE Walk through the examples of different options available in a lattice of plots. Take longer on this macro call than the others as it is more complicated FOOTNOTE OVFOOTNOTE
9
Output Methods RTF, PDF, HTML, Listing
Various file types (PNG, JPEG, TIFF, EMF, …) DPI settings Scalable vector graphics (9.3 and later) From macro vs. within ODS tags Quick overview of different output methods available to the macro.
10
Error Checking Macro checks most parameter input
Custom error messages: ERROR: (Model 1: DISPLAY): TOTL is not in the list of valid values ERROR: (Model 1: DISPLAY): Possible values are LEGEND|HR|MEDIAN|TOTAL|EVENT|TIMELIST| PVAL|TABLECOMMENTS ERROR: 1 pre-run errors listed ERROR: Macro NEWSURV will cease
11
Computed Statistics 1 LIFETEST procedures, up to 2 PHREG procedures
N patients, N events Median time-to-event Kaplan-Meier event-free rate Cox proportional hazards ratio Univariate and adjusted P-value Patients-at-risk numbers This section will describe the statistics that are computed within the macro, where they come from, and how they are saved into datasets Explain why there are two LIFETEST procedures Explain that the following slides will show a data set by data set walkthrough, but they are not all unique procedure calls.
12
LIFETEST – ODS Output SURVIVALPLOT #1
ODS GRAPHICS ON; PROC LIFETEST DATA=sashelp.bmt PLOT=(SURVIVAL(CL)); STRATA group; TIME t*status(0); ODS OUTPUT SURVIVALPLOT=os1; RUN; This is where the values for the Kaplan-Meier curves come from
13
LIFETEST – ODS Output SURVIVALPLOT #2
ODS GRAPHICS ON; PROC LIFETEST DATA=sashelp.bmt PLOT=(SURVIVAL(ATRISK=1000,2000)); STRATA group; TIME t*status(0); ODS OUTPUT SURVIVALPLOT=splot (KEEP=time tatrisk stratumnum atrisk WHERE=(tatrisk ^=.)); RUN; This is where the values for the patients-at-risk numbers come from
14
LIFETEST – OUTSURV Option w/REDUCEOUT OPTION
PROC LIFETEST DATA=sashelp.bmt OUTSURV=os2 REDUCEOUT TIMELIST= ; STRATA group; TIME t*status(0); RUN; This is where the event-free rate estimates come from The REDUCEOUT option is the reason why there are two LIFETEST procedures
15
LIFETEST – ODS Output CENSOREDSUMMARY
PROC LIFETEST DATA=sashelp.bmt; STRATA group; TIME t*status(0); ODS OUTPUT CENSOREDSUMMARY=summary; RUN; This is where the number of patients and number of events come from
16
LIFETEST – ODS Output QUARTILES
PROC LIFETEST DATA=sashelp.bmt; STRATA group; TIME t*status(0); ODS OUTPUT QUARTILES=quartiles; RUN; This is where the median time-to-event estimates come from
17
LIFETEST – ODS Output HOMTESTS
PROC LIFETEST DATA=sashelp.bmt; STRATA group / logrank wilcoxon; TIME t*status(0); ODS OUTPUT HOMTESTS=pval1; RUN; This is where the logrank and Wilcoxon p-values come from
18
PHREG #1 – ODS Output PARAMETERESTIMATES
PROC PHREG DATA=sashelp.bmt; CLASS group; MODEL t*status(0) = group / RISKLIMITS; ODS OUTPUT PARAMETERESTIMATES=hazards (keep=classval0 hazardratio hrlowercl hruppercl); RUN; This is where the hazard ratios and 95% CI come from Mention that the macro can also do adjusted hazard ratios
19
PHREG #1 – ODS Output TYPE3
PROC PHREG DATA=sashelp.bmt; CLASS group; MODEL t*status(0) = group / TYPE3(score lr wald); ODS OUTPUT TYPE3=pval2 (keep=effect problrchisq probscorechisq probchisq); RUN; This is where the likelihood-ratio and score type 3 p-values come from
20
PHREG #2 – Adjusted Models
A second PHREG is run if adjusting covariates are added to the model Outputs statistics with same method as PHREG #1 Output datasets limited down to CLASS variable only This is where the likelihood-ratio and score type 3 p-values come from
21
Statistics Saved as Macro Variables
SQL Procedure SUMMARY OS2 QUARTILES HAZARDS PVAL1 PVAL2 N patients/events Event-free rates Median time-to-event Hazard ratios Logrank/Wilcoxon Score/Likelihood-ratio/Wald PROC SQL pulls macro variables with INTO statements
22
Plot Data Set Only variables used in plot statements Step plots
Censor scatterplots Patients-at-risk block plots Only variables that are used in the Template procedure are included in the data set. Plot data set Plotting Kaplan-Meier curves Plotting censor indicators Plotting patients-at-risk numbers Setting up the plot window Summary statistics table Be ready to explain the arrows
23
Plot Data Set – Step Plot and Censor Scatterplot Columns
Variables Cl#_#: CLASS level T#_#: time C#_#: Survival function estimate when censor S#_#: Survival function estimate #_#: First #: CLASS level number Second #: model number These set of columns for each Kaplan-Meier Curve Explain the numbering Explain what is meant by models Explain what is meant by class level
24
Plot Data Set – Step Plot and Censor Scatterplot Columns
This is a sample of the columns produced by the macro to make the Kaplan-Meier curves One set of four columns for each line
25
Multiple Plots in One Window
One STEPPLOT statement Multiple STEPPLOT statement STEPPLOT X=t Y=survival / GROUP=group NAME=‘stepplot’ LINEATTRS=(THICKNESS=4pt); DISCRETELEGEND ‘stepplot’ / …; STEPPLOT X=t3 Y=survival3 / LEGENDLABEL=“AML-Low Risk” NAME=‘stepplot3’ LINEATTRS=(THICKNESS=4pt COLOR=cx01665E PATTERN=8); DISCRETELEGEND ‘stepplot1’ ‘stepplot2’ ‘stepplot3’/ …; STEPPLOT X=t1 Y=survival1 /…; STEPPLOT X=t1 Y=survival1 / LEGENDLABEL=“ALL” NAME=‘stepplot1’ LINEATTRS=(THICKNESS=4pt COLOR=blue PATTERN=1); STEPPLOT X=t2 Y=survival2 / LEGENDLABEL=“AML-High Risk” NAME=‘stepplot2’ LINEATTRS=(THICKNESS=4pt COLOR=cxB2182B PATTERN=4); STEPPLOT X=t2 Y=survival2 /…; Why are each of the lines plotted individually? How are they? Show there is no difference in appearance between using a group option vs. plotting each line separately. Easier to customize when dealing with the separate stepplot statements than with a group option.
26
Turn Data by Categorical Variable into Multiple Variables
DATA _plot; MERGE os1 (WHERE=(group=“ALL”) RENAME=(t=t1 survival=survival1) KEEP=t1 survival1) os1 (WHERE=(group=“AML-High Risk”) RENAME=(t=t2 survival=survival2) KEEP=t2 survival2) (WHERE=(group=“AML-Low Risk”) RENAME=(t=t3 survival=survival3) KEEP=t3 survival3); RUN; Same data set merging with itself Keeps each class level Renames variables
27
Plot Data Set – Patients-at-risk Block Plot Variables
Time#_#: time-point values Atrisk#_#: Number of patients-at-risk partitle_#: Header text string #_#: First #: CLASS level number Second #: model number _#: model number Same naming scheme Three columns for each of the scatterplots Explain the EVAL Function briefly
28
How Block Plots Can Make Tables
1 38 20 12 11 4 1 MARKERCHARACTER option allows a column of values to become the symbols in the scatterplot 1 2 3 4 5 6 BLOCKPLOT X=time1_1 BLOCK=atrisk1_1 / … VALUEHALIGN=START DISPLAY=(VALUES LABEL); BLOCKPLOT X=time1_1 BLOCK=atrisk1_1 / … VALUEHALIGN=START DISPLAY=(OUTLINE VALUES LABEL); BLOCKPLOT X=time1_1 BLOCK=atrisk1_1 / … VALUEHALIGN=LEFT DISPLAY=(OUTLINE VALUES LABEL);
29
Plot Data Set – Patients-at-risk Block Plot Variables
Set of columns for each class level
30
Plot Layout Plot Window
Model Title Model Footnote Plot Window X - Label Y L a b e l 5 10 15 20 25 30 I N E R M A G B o c k Model Title Model Footnote Plot Window X - Label Y L a b e l Class Level 1 2 3 5 10 15 20 25 30 Model Title Model Footnote Plot Window X-Label Y-Label 5 10 15 20 25 30 Patients - at Risk Header 50 45 30 22 6 3 60 52 37 26 18 7 4 34 20 12 9 2 Class Level 1 Patients - at Risk Header 50 45 30 22 6 3 60 52 37 26 18 7 4 34 20 12 9 2 First image: Explain what layout lattice is. Explain that layout lattice opens up more text field options Layout lattice can be used with only one cell if only to use these other spaces for text statements Second image: Show how the window for each plot makes use of its own lattice layout Titles and footnotes in sidebar blocks patients-at-risk when set to below x-axis Image taken from SAS 9.3 Graph Template Language Reference
31
Plot Layout Inner Margin Block
This title is placed inside of a SIDEBAR block with ALIGN=TOP This footnote is placed inside of a SIDEBAR block with ALIGN=BOTTOM 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 Time (Years) 0.1 0.2 0.3 0.4 0.6 0.7 0.8 0.9 Proportion Alive and Disease-Free Censor 6.0 (1.9-NE) 25 54 AML-Low Risk 0.5 ( ) 34 45 AML-High Risk 1.1 (0.5-NE) 24 38 ALL Median (95% CI) Event Total Disease Group Inner Margin Block This title is placed inside of a SIDEBAR block with ALIGN=TOP This footnote is placed inside of a SIDEBAR block with ALIGN=BOTTOM Patients-at-Risk 38 26 20 14 12 11 7 4 1 45 23 17 13 10 8 6 3 2 54 47 42 36 33 29 24 19 AML-Low Risk AML-High Risk ALL 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 Time (Years) 0.1 0.2 0.3 0.4 0.6 0.7 0.8 0.9 Proportion Alive and Disease-Free Censor 6.0 (1.9-NE) 25 0.5 ( ) 34 1.1 (0.5-NE) Median (95% CI) Event Total Disease Group Show how the schematic layout lines up with an actual plot example
32
Lattice of Plots Any rectangular array Fully Customizable
Each model’s option separated by | delimiter Number of plots is determined by number of time variables
33
Lattice Layout of Plots Process Flow
Temporary data set w/transformations Begin template and define number of cells Analysis procedures Create cell axes Create plot and output data sets Error Checking Run plot statements Run output options Create macro variables for ENTRY statements Explain first, then run animation Shows the process flow of the macro when multiple models are run in one macro call SGRENDER procedure Delete temporary datasets REPORT procedure
34
Plot Summary Table Transition into the plot summary table
35
ENTRY Statements Create text Placed inside/outside plot
LAYOUT GRIDDED / ROWS=2 HALIGN=right VALIGN=top BORDER=true; ENTRY HALIGN=left ‘Green Text’ / VALIGN=top TEXTATTRS= (COLOR=green SIZE=14pt); ENTRY HALIGN=left ‘Black Text’ (COLOR=black SIZE=14pt); ENDLAYOUT; Create text Placed inside/outside plot Anchored by combination of position terms Left/Center/Right Top/Center/Bottom Powerful w/LAYOUT GRIDDED Green Text Black Text Red Text Black Text Green Text ENTRY HALIGN=left ‘Green Text’ / VALIGN=top TEXTATTRS= (COLOR=green SIZE=14pt); ENTRY HALIGN=left ‘Black Text’ (COLOR=black SIZE=14pt); ENTRY HALIGN=center 'Red Text‘ / VALIGN=top TEXTATTRS= (COLOR=red SIZE=14pt); ENTRY HALIGN=left ‘Blue Text’ / VALIGN=bottom TEXTATTRS= (COLOR=blue SIZE=14pt); ENTRY HALIGN=right "X" {sup "2"} {unicode "2264"x} "64" / VALIGN=bottom TEXTATTRS=(COLOR=black SIZE=14pt); 1 X 2 <64 Blue Text 1 2 3 4 5 6 Walk through the different entry statements Give a description of layout gridded
36
LAYOUT GRIDDED Class N Median (95% CI) Time-Point KM Est ALL 38
1.1 (0.5-NE) 1 Year 0.55 2 Years 0.35 AML High-Risk 45 0.5 ( ) 0.38 AML Low-Risk 54 6.0 (1.9-NE) 0.78 Makes a rectangular grid Each cell can contain ENTRY statements Plot statements Legend statements Automatically sized Can be nested within itself
37
Non-Visible Items Still Take up Space
STEPPLOT X=t1 Y=survival1 / LINEATTRS=(color=white) NAME='white' LEGENDLABEL='White Line'; STEPPLOT X=t1 Y=survival1 / NAME=‘class1’ …; STEPPLOT X=t2 Y=survival2 / NAME=‘class2’ …; STEPPLOT X=t3 Y=survival3 / NAME=‘class3’ …; LAYOUT GRIDDED / COLUMNS=1 ROWS=2 …; DISCRETELEGEND ‘class1’ ‘class2’ ‘class3’ / …; DISCRETELEGEND 'white' / BACKGROUNDCOLOR=red OPAQUE=true …; ENDLAYOUT; 250 500 750 1000 1250 1500 1750 2000 2250 2500 2750 3000 Disease-Free Survival Time 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 Survival Distribution Function Estimate White Line AML Low-Risk AML High-Risk ALL White Line AML Low-Risk AML High-Risk ALL Explain that the next two slides include tricks that are used in order to make the plot summary table This slide contains an example of an item that cannot be seen, but can still be made useful for plotting purposes. Focus on text by the arrow
38
Rendering in Order 250 500 750 1000 1250 1500 1750 2000 2250 2500 Disease-Free Survival Time 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 Survival Distribution Function Estimate ALL Black ALL AML-High Risk AML-Low Risk SCATTERPLOT X=t2 Y=survival2 / MARKERATTRS=(symbol=diamondfilled color=black) NAME='black' LEGENDLABEL='ALL Black'; SCATTERPLOT X=t Y=survival / MARKERATTRS=(symbol=diamondfilled) GROUP=group NAME='group'; DISCRETELEGEND 'black' 'group' / …; Explain how choosing a specific rendering order can lead to useful features Overwriting certain lines Using objects for legends, creating new looking graphics, etc.
39
Plot Summary Table Design
+ . 61 ( 49 - 76 ) Legend Class Value Total Events Time Point KM Estimate Score P value : 0010 Censor Table Comment 1 2 3 ALL AML High Risk Low Risk 38 45 54 24 34 25 Years 55 41 73 35 23 26 15 78 67 90 Walk through how to next layout gridded statements in order to create a formatted table Show where the previous tricks come into play Explain dynamic ability to change
40
Statistical Report Table
General Statistical Report Table Example Event/Total Median (95% CI)† Hazard Ratio (95% CI)‡ Survival Estimates (95% CI)† P-value SASHELP.BMT Data set with no Class Variable All Patients 83/137 1.3 ( ) 1 Years: ( ) 2 Years: ( ) This is the footnote for this model SASHELP.BMT Data set with Class Variable Group 0.0010$ ALL 24/38 1.1 (0.5-NE) Ref 1 Years: ( ) 2 Years: ( ) AML-High Risk 34/45 0.5 ( ) 1.47 ( ) 1 Years: ( ) 2 Years: ( ) AML-Low Risk 25/54 6.0 (1.9-NE) 0.56 ( ) 1 Years: ( ) 2 Years: ( ) †Kaplan-Meier method; ‡Cox model; $Score test; This also allows an overall footnote Walk through highlighting the customizability of the table Imports the titles/footnotes from plots Automatically generated footnotes
41
Multiple Macro Calls Can be Output in the same Report
Event/Total Survival Estimates (95% CI)† All Patients, In Years, Survival at 1 Year, Using Proportions Disease Group ALL 24/38 1 Year: ( ) AML-High Risk 34/45 1 Year: ( ) AML-Low Risk 25/54 1 Year: ( ) This comes from the first macro call Time Landmarked at 500 Days, In Days, Subsequent Survival at 365 Days, Using Percentages 3/16 365 Days: ( ) 2/13 365 Days: ( ) 7/36 365 Days: ( ) This comes from the second macro call †Kaplan-Meier method; %NEWSURV(…, summary=0,out=table); %NEWSURV(…, summary=1,out=table, newtable=0); Ability to make multiple runs of the macro save to the dame dataset Ability to make the last macro call output the dataset with all of the analysis
42
Contact Information Name: Jeffrey Meyers Enterprise: Mayo Clinic Address: 200 1st St SW City, State ZIP: Rochester, MN 55905 Work Phone: Twitter: jmeyers_spa
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.