Customizing the Kaplan-Meier Survival Plot


Graph Templates, Macros, and Macro Variables

The %ProvideSurvivalMacros macro and the macros and macro variables that it provides have the following properties:

  • Many options, including most of the options that are specified in multiple places in the templates, are extracted to macro variables.

  • The %CompileSurvivalTemplates macro provides the main body of the two templates. You can call it to compile the templates after making changes.

    • The template Stat.Lifetest.Graphics.ProductLimitSurvival provides the survival template when the at-risk table is inside the body of the plot.

    • The template Stat.Lifetest.Graphics.ProductLimitSurvival2 provides the survival template when the at-risk table is outside the body of the plot.[18]

    The two templates share many statements, and a macro %DO loop creates both versions.

  • The portion of the templates for the table for the p-values is stored in the macro %pValue.

  • The portion of the templates for the single-stratum case is stored in the macro %SingleStratum.

  • The portion of the templates for the multiple-strata case is stored in the macro %MultipleStrata.

  • The macro %AtRiskLatticeStart begins the two-cell lattice that contains the plot above the table when the at-risk table is outside the body of the plot.

  • The macro %AtRiskLatticeEnd ends the two-cell lattice that contains the plot and the table when the at-risk table is outside the body of the plot.

  • Some empty macros (%StmtsBeginGraph, %StmtsTop, and %StmtsBottom) are provided to enable you to add statements and options to strategic places in the templates.

  • The %SurvTabHeader, %SurvivalTable, and %SurvivalSummaryTable macros enable you to easily add more GTL statements to the Kaplan-Meier plot templates to display event information for each stratum.

This organization makes it easy to identify the relevant parts of the templates, modify these parts, and recompile the templates. A small portion of the %ProvideSurvivalMacros macro follows:

%macro ProvideSurvivalMacros;

   %global atriskopts bandopts censored censorstr classopts
           graphopts groups insetopts legendopts ntitles stepopts tiplabel
           tips titletext0 titletext1 titletext2 xoptions yoptions;

   %let TitleText0 = METHOD " Survival Estimate";
   %let TitleText1 = &titletext0 " for " STRATUMID;
   %let TitleText2 = &titletext0 "s";         /* plural: Survival Estimates */

   %let yOptions   = label="Survival Probability" shortlabel="Survival"
                     linearopts=(viewmin=0 viewmax=1
                                 tickvaluelist=(0 .2 .4 .6 .8 1.0));

   %let xOptions   = shortlabel=XNAME offsetmin=.05
                     linearopts=(viewmax=MAXTIME tickvaluelist=XTICKVALS
                                 tickvaluefitpolicy=XTICKVALFITPOL);
   . . .

   %macro CompileSurvivalTemplates; . . . %mend;
   %macro pValue;                   . . . %mend;
   %macro SingleStratum;            . . . %mend;
   %macro MultipleStrata;           . . . %mend;
   . . .
%CompileSurvivalTemplates
%mend;


[18] The macros do not affect any graph that uses graph templates other than the two templates that are modified here. The macrosdo not affect the STRATA=PANEL plot that uses the template Stat.Lifetest.Graphics.ProductLimitSurvivalPanel or the failure plot that uses the template Stat.Lifetest.Graphics.ProductLimitFailure.