BookmarkSubscribeRSS Feed
lmyers2
Obsidian | Level 7

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;

 

2 REPLIES 2
lmyers2
Obsidian | Level 7

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3035 views
  • 0 likes
  • 2 in conversation