SAS provides the two templates that are used to make the survival plot in a modularized form.[13] The modularized version of the two survival plot templates is available in the SAS sample library and is on the Web at http://support.sas.com/documentation/onlinedoc/stat/ex_code/131/templft.html.
The file defines the macro %ProvideSurvivalMacros, which defines a series of macros and macro variables. The %ProvideSurvivalMacros macro contains a %GLOBAL statement, a series of %LET statements, and several macro definitions. It ends with a call to the %CompileSurvivalTemplates macro (which is defined inside the %ProvideSurvivalMacros macro), which compiles the two survival plot templates.[14] By using these macros and macro variables, you can easily specify single changes that modify both templates. All the statements in this file are displayed and explained in more detail in the section Graph Templates, Macros, and Macro Variables.
The %ProvideSurvivalMacros macro provides a way to provide (and in subsequent steps restore) the default macros and macro variables. The macros and macro variables are designed so that you can make most changes by submitting just a few lines of SAS code. Hence, you should not modify any of the statements while they are inside the %ProvideSurvivalMacros macro. Rather, you should use this macro only to provide all the default macros and macro variables. You should modify the individual macros and macro variables outside the context of the %ProvideSurvivalMacros macro.[15] The reasons for this will become clearer as you work through the examples. Before you modify anything, you must submit the %ProvideSurvivalMacros macro definition from the sample library to SAS. You can both store the macros in a temporary file and submit them to SAS by submitting the following statements:
data _null_; %let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/131; infile "http:&url/templft.html" device=url; file 'macros.tmp'; retain pre 0; input; if index(_infile_, '</pre>') then pre = 0; if pre then put _infile_; if index(_infile_, '<pre>') then pre = 1; run; %inc 'macros.tmp' / nosource;
Submitting these statements only defines the %ProvideSurvivalMacros macro. It does not make any of its component macros and
macro variables available. The URL
macro variable is used to avoid an overly long INFILE statement.
You can provide the default macros and macro variables by running the following macro:
%ProvideSurvivalMacros
Running this macro provides the default macros and macro variables (or restores them if you have previously submitted the %ProvideSurvivalMacros macro).[16] The %ProvideSurvivalMacrosmacro also runs the %CompileSurvivalTemplates macro and hence replaces any compiled survival plot templates that you might have created in the past. You can recompile the templates by submitting the following macro:
%CompileSurvivalTemplates
This macro runs PROC TEMPLATE and compiles the templates from all the macros and macro variables in the %ProvideSurvivalMacros
macro along with any that you modified. Running this macro produces two compiled templates that are stored in a special SAS
data file called an item store. For more information about SAS item stores, see the section SAS Item Stores. Assuming that you have not modified your ODS path by using an ODS PATH statement, compiled templates are stored in an item
store in the Sasuser
library. Files in the Sasuser
library persist across SAS sessions until they are deleted. When you are done with a modified template, it is wise to clean
up all remnants of it by restoring the default macros and by deleting the modified templates from the Sasuser
template item store. You can delete the modified templates (so that SAS can only find the original templates) by running
the following step:
proc template; delete Stat.Lifetest.Graphics.ProductLimitSurvival / store=sasuser.templat; delete Stat.Lifetest.Graphics.ProductLimitSurvival2 / store=sasuser.templat; run;
This step deletes the compiled templates from the item store sasuser.templat
. You can omit the STORE= option if you are using the default ODS path, but it is good practice to explicitly control which
templates are deleted. Deleting the compiled templates does not change any of the macros or macro variables. Only the compiled
templates (not the macros or macro variables) affect the graph when you run PROC LIFETEST. For more information about compiled
templates, item stores, and cleanup, see the section SAS Item Stores.
[13] The two templates that PROC LIFETEST uses are named Stat.Lifetest.Graphics.ProductLimitSurvival
and Stat.Lifetest.Graphics.ProductLimitSurvival2
.
[14] You might wonder why these macros are not simply made available in the SAS autocall library. The autocall library provides macros that you can run. In this context, you do not need to simply run a macro. You need to copy it, extract parts of it, modify those parts, and submit the modified statements. That is not convenient with the autocall library.
[15] However, there might be something that you always want to change. For example, if you always want the survival plot to be entitled 'Kaplan-Meier Plot', then you can modify the title once inside the %ProvideSurvivalMacros macro. This is not illustrated in this chapter. All examples illustrate ad hoc changes that are made outside the context of the %ProvideSurvivalMacros macro.
[16] Semicolons are not needed after a macro call like this one, so they are not used in these examples.