Hello,
I'm using sas 9.4. I've been reading how to change the title of a survival plot and x-axis but don't understand how to use the following macro I found. Do I run proc template first, then run this macro? How do I change this macro to get the title to be "Kaplan Meier Plot" and X-axis "Time (weeks)"?
%macro SurvivalTemplate;
%local outside;
proc template;
%do outside = 0 %to 1;
define statgraph Stat.Lifetest.Graphics.ProductLimitSurvival%scan(2,2-&outside);
dynamic NStrata xName plotAtRisk %if %nrbquote(&censored) ne %then plotCensored;
plotCL plotHW plotEP labelCL labelHW labelEP maxTime xtickVals xtickValFitPol
rowWeights method StratumID classAtRisk plotBand plotTest GroupName yMin
Transparency SecondTitle TestName pValue _byline_ _bytitle_ _byfootnote_;
BeginGraph;
if (NSTRATA=1)
if (EXISTS(STRATUMID)) entrytitle &titletext1;
else entrytitle &titletext0;
endif;
%if not &outside %then if (PLOTATRISK);
entrytitle "With Number of Subjects at Risk" / textattrs=GRAPHVALUETEXT;
%if not &outside %then %do; endif; %end;
%AtRiskLatticeStart
layout overlay / xaxisopts=(&xoptions) yaxisopts=(&yoptions);
%singlestratum
endlayout;
%AtRiskLatticeEnd
else
entrytitle &titletext2;
if (EXISTS(SECONDTITLE))
entrytitle SECONDTITLE / textattrs=GRAPHVALUETEXT;
endif;
%AtRiskLatticeStart
layout overlay / xaxisopts=(&xoptions) yaxisopts=(&yoptions);
%multiplestrata
endlayout;
%AtRiskLatticeEnd(%str(class=CLASSATRISK))
endif;
if (_BYTITLE_) entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
else if (_BYFOOTNOTE_) entryfootnote halign=left _BYLINE_; endif;
endif;
EndGraph;
end;
%end;
run;
%mend;
Use this chapter instead.
Thanks
I'm guessing I'm not running the code right because the title remains "Product-Limit Survival Estimate." I also tried to change the code to make the title of the x-axis title "Time (weeks)." Code is below.
proc template;
define statgraph Stat.Lifetest.Graphics.ProductLimitSurvival;
%ProvideSurvivalMacros
%let TitleText0 = "Kaplan-Meier Plot";
%let TitleText1 = "Time (weeks)";
%let TitleText2 = &titletext0;
%CompileSurvivalTemplates
ods graphics on;
proc lifetest data=ecmodata plots=survival (cb=hw atrisk(outside(0.15)));
time survt * status(0);
run;
ods graphics off;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.