In a previous article, I described Using SAS ODS Graphics with Example for Generating Kaplan-Meier Curves. The graph template was utilized for modifying the features of the Kaplan Meier curve. However, the process is very cumbersome since we have to make sure that we identify the correct template and we have to copy and paste the lengthy template into the SAS program. The graph template language (GTL) was not easy to read and modify.
Luckily, SAS has now provided detail instructions for customizing the Kaplan-Meier plot. It also developed several macros to let users to modify the relevant sections of the graph template without actually copying and pasting the lengthy graph template languages into the program.
Here are the User’s guide for SAS version 9.4 and 9.3.
- SAS/Stat 14.1 User’s Guide Customizing the Kaplan-Meier Survival Plot
- SAS/STAT® 13.1 User’s Guide Customizing the Kaplan-Meier Survival Plot
data _null_;
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/141;
*for SAS 9.4;
*%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/131;
*for SAS 9.3;
infile "http:&url/templft.html" device=url;
file 'macros.tmp';
retain pre 0;
input;
if index(_infile_, '') then pre = 0;
if pre then put _infile_;
if index(_infile_, '') then pre = 1;run;
%inc 'macros.tmp' / nosource;
User’s Guide describes two macros ProvideSurvivalMacros and CompileSurvivalTemplates. With these two macros, the Kaplan-Meier plot can be customized with several easily understood statements. Below is an example program to further modifying the Kaplan-Meier plot that was generated in the previous blog. Some notes are added to indicate the purpose of each statement.
%ProvideSurvivalMacros
%let TitleText0 = "Kaplan-Meier Plot of Disease Free Time";
*Change the title;
*Change the title;
%let TitleText1 = &titletext0 " for " STRATUMID;
%let TitleText2 = &titletext0;
%let ntitles=1; *suppressing the second title;
%macro StmtsBeginGraph; *add footnote;
entryfootnote halign=left "ABC Pharmaceuticals %sysfunc(date(),worddate.)" /
textattrs=GraphDataText;
%mend;
%let GraphOpts = attrpriority=none DataLinePatterns=(solid ShortDash LongDash);
*change line pattern;
%let yOptions = label="Patients without an event (%)"
linearopts=(viewmin=0 viewmax=1
tickvaluelist=(0 .25 .50 .75 1) tickdisplaylist=('0' '25' '50' '75' '100')) ;
*modify y-axis label and display as percentage instead of fraction;
%let xOptions = label="Disease Free Time (days)" offsetmin=0
linearopts=(viewmin=0 viewmax=2500
tickvaluelist=(0 500 1000 1500 2000 2500)
tickvaluefitpolicy=XTICKVALFITPOL); *modify x-axis;
tickvaluelist=(0 500 1000 1500 2000 2500)
tickvaluefitpolicy=XTICKVALFITPOL); *modify x-axis;
%let InsetOpts = ; *Remove the legend for censored value;
%let LegendOpts = title='' location=inside across=1 autoalign=(BottomRight);
*change the legend for treatment group;
%CompileSurvivalTemplates /* Compile the templates with upated information*/
ods rtf file="c:\temp\test.doc" style=journal;
ods graphics on/noborder; *remove the border of the graph area;
ods noptitle; *remove the default title;
title; *remove the default title 'SAS System';
ods trace on;
proc lifetest data=BMT plot=survival(nocensor atrisk(outside maxlen=13
atrisktick)=0 to 2500 by 500);
*Place the atrisk outside;
atrisktick)=0 to 2500 by 500);
*Place the atrisk outside;
ods select SurvivalPlot;
time T * Status(0);
strata Group / test=logrank adjust=sidak;
run;
run;
ods trace off;
ods graphics off;
ods rtf close;
proc template;
delete Stat.Lifetest.Graphics.ProductLimitSurvival;
delete Stat.Lifetest.Graphics.ProductLimitSurvival2;
run;
The output graph is attached here.
3 comments:
Happy New Year!
Professor, have you had experience when the client asks for the KM curve to be produced as an increasing/upward line? I have been recently, where the client only wants to produce the mirror image of the typical KM curve. In essence, the graph would display incidents (or events) over time, rather than S(t) over time.
They still want to call this as "KM estimate over time", but I believe this is really something like a cumulative incidence graph. Do you have any reservations in producing this type of cumulative incidence graphs as oppose to the traditional KM curve?
Thanks
yes, it is also pretty common to draw the K-L plot as an increasing/upward line.
in a previous article, the example was for the plot in this way.
http://onbiostatistics.blogspot.com/2012/10/using-sas-ods-graphics.html
If you use the Proc Lifetest, you can draw the failure plot instead of the survival plot. alternatively, you can output the data from Proc Lifetest and then calculate 1-s(t) to get the numbers for the upward line.
hi, you have give an a very useful information about the biostatics and clinical trails of sas technologies and for additional information visit the given link http://www.flaxit.com/sas-clinical-online-training/.
Post a Comment