Hello,
Using SAS 9.4
I am trying to change the title of a proc lifetest but using the %ProvideSurvivalMacros and the documentation that comes from here (https://support.sas.com/documentation/cdl/en/statug/67523/HTML/default/viewer.htm#statug_kaplan_sect...).
However, I cannot seem to get the title to change. I have attached my code because I am obviously missing something. Any help would be greatly appreciated. Thank you
data _null_;
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/132;
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;
%ProvideSurvivalMacros
%let TitleText0 = "Figure 1";
%CompileSurvivalTemplates
ODS LISTING image_dpi=300 GPATH = 'path' style=statistical;
ODS GRAPHICS ON / IMAGENAME = "Figure 1" IMAGEFMT=tiff HEIGHT=5in WIDTH=15cm
attrpriority=Color;
proc lifetest data=cr.analysis OUTCIF=cif_output atrisk plots=cif(test) maxtime=600 NINTERVAL=100 timelist= 0 25 50 75 100 200 300 400 500 600;
time tt_censor_date*binary_amputation(0)/eventcode=1;
label tt_censor_date = 'Time (in wks) from DOS to Censor Date'
gender = 'Gender';
strata gender;
ods output GrayTest=graytest;
run;
proc template;
delete Stat.Lifetest.Graphics.ProductLimitSurvival /
store=sasuser.templat;
delete Stat.Lifetest.Graphics.ProductLimitSurvival2 /
store=sasuser.templat;
run;
Sometimes you need to read the fine print as well as the code example. From the linked documentation page: (emphasis added )
There are multiple title macro variables because two different types of plots are defined in the survival plot templates. The first macro variable,
TitleText0
, contains the text that is the same for both types of plots. The second macro variable,TitleText1
, contains the title for the single-stratum case. The third macro variable,TitleText2
, contains the title for the multiple-strata case. BothTitleText1
andTitleText2
use the common text defined inTitleText0
. BothTitleText0
andTitleText2
were changed from their original definition; the definition ofTitleText1
was copied from the %ProvideSurvivalMacros macro. You must provide all relevant %LET statements when you modifyTitleText0
. In this case it isTitleText0
andTitleText2
, but it is easy to copy all three and then just modify what you need. Alternatively, when you know the number of strata, you can modify onlyTitleText1
orTitleText2
.
So add the the other 2 TitleText macro variables and you should be good to go.
I added the 2 lines and that did not fix the problem. Do you have any other thoughts on why this is not working? Thank you
data _null_;
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/132;
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;
%ProvideSurvivalMacros
%let TitleText0 = "Figure 1";
%let TitleText1 = &titletext0 " for " STRATUMID;
%let TitleText2 = &titletext0;
%CompileSurvivalTemplates
ODS LISTING image_dpi=300 GPATH = 'path' style=statistical;
ODS GRAPHICS ON / IMAGENAME = "Figure 1" IMAGEFMT=tiff HEIGHT=5in WIDTH=15cm
attrpriority=Color;
proc lifetest data=cr.analysis OUTCIF=cif_output atrisk plots=cif(test) maxtime=600 NINTERVAL=100 timelist= 0 25 50 75 100 200 300 400 500 600;
time tt_censor_date*binary_amputation(0)/eventcode=1;
label tt_censor_date = 'Time (in wks) from DOS to Censor Date'
gender = 'Gender';
strata gender;
ods output GrayTest=graytest;
run;
proc template;
delete Stat.Lifetest.Graphics.ProductLimitSurvival /
store=sasuser.templat;
delete Stat.Lifetest.Graphics.ProductLimitSurvival2 /
store=sasuser.templat;
run;
I don't have your data so cannot run all your code.
Is your log showing any warnings or errors? If so, set OPTIONS MPRINT; to get details of what is happening when the macros run and see if that shows anything.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.