Hi everyone,
i am trying o edit the failure curve obtained from proc life, see the code below:
DATA Have;
input id os_censor Sex $ Age duration os progress $ trt $;
LABEL os = 'Overall Survival (months)'
progress = 'Progression'
trt = 'Treatment'
duration = 'Duration of Radiation';
DATALINES;
1 1 M 40 44 20 No B
2 1 F 45 46 16 Yes A
3 1 F 40 32 20 No B
4 1 F 47 32 23 No B
5 0 M 41 25 22 No B
6 1 M 54 35 13 No B
7 1 M 48 50 9 Yes A
8 1 M 36 33 12 Yes B
9 0 F 49 51 8 Yes A
10 1 M 49 52 10 Yes A
11 1 M 44 35 12 No A
12 1 M 49 50 8 Yes A
13 1 M 44 44 14 Yes A
14 1 M 50 31 10 Yes A
15 1 M 53 40 15 No B
16 0 M 52 29 20 Yes B
17 1 F 46 45 5 Yes A
18 1 F 37 44 11 Yes A
19 1 M 49 46 13 No B
20 1 M 42 31 11 No A
;
run;
proc template;
delete Stat.Lifetest.Graphics.ProductLimitFailure2;
source Stat.Lifetest.Graphics.ProductLimitFailure2 / file='tpl.tpl';
quit;
data _null_;
infile 'tpl.tpl' end=eof;
input;
if _n_ eq 1 then call execute('proc template;');
_infile_ = tranwrd(_infile_, 'viewmax=1',
'viewmax=100');
_infile_ = tranwrd(_infile_, '1-', '100-100*');
_infile_ = tranwrd(_infile_, 'Failure Probability', 'Percentage, failing');
call execute(_infile_);
if eof then call execute('quit;');
run;
proc template;
source Stat.Lifetest.Graphics.ProductLimitFailure2 /
store=sasuser.templat file='tplmod.tpl';
quit;
proc lifetest data=have atrisk plots=survival(atrisk (atrisktickonly outside ) failure test ) ;
strata trt;
time os*os_censor(0);
run;
I am still having two problems that I would appreciate help with:
1. I am unable to edit the title of the figure (Product limit Failure Curves With Number of Subjects at Risk), but have not been able to change that title.
2. The y axis, while now converted to percentages, the axis label itself is not correct.
I appreciate your help with this..
Changing a dynamic variable METHOD to literal text:
_infile_ = tranwrd(_infile_, 'entrytitle METHOD', 'entrytitle "MY-TITLE"');
Solved the axis issue:
data _null_;
infile 'tpl.tpl' end=eof;
input;
if _n_ eq 1 then call execute('proc template;');
_infile_ = tranwrd(_infile_, 'viewmax=1', 'viewmax=100');
_infile_ = tranwrd(_infile_, '1-', '100-100*');
_infile_ = tranwrd(_infile_, '(0 .2 .4 .6 .8 1.0)', '(0 20 40 60 80 100)');
_infile_ = tranwrd(_infile_, 'Failure Probability', 'Percentage, Failing');
call execute(_infile_);
if eof then call execute('quit;');
run;
But really not getting anywhere with the title issue
Hope someone could help
It looks like you were looking at something I wrote somewhere. You are creating a file called tpl.tpl that contains the original SAS-provided templates. Look at that file with an ordinary text editor. Find the lines you want to change. Then add the right translations to your DATA step to make the changes you want.
Thanks @WarrenKuhfeld you are absolutly correct.
i already tried to do that with a text editor but faced two problems:
1. The word 'product limit' does not appear in the template file at all!
2. Even when changing 'With Number of Subjects at Risk' using the same strategy in
_infile_ = tranwrd(_infile_, 'With Number of Subjects at Risk', 'Patients at risk');
SAS will still force 'With Number of Subjects at Risk' to appear.
i also tried 'ProvideSurvivalMacro' but no luck!
The failure curves are causing the code 'to fail' 🙂
I will try running it on Monday if you have not figured it out by then.
You should know that text in graphs come from two places:
If you see a variable-name-looking-thing on a statement or in an option in a template instead of a literal text string, and you also see that name in a dynamic statement, then that is a dynamic variable. For ad hoc changes, replace the dynamic variable with a literal text string.
Changing a dynamic variable METHOD to literal text:
_infile_ = tranwrd(_infile_, 'entrytitle METHOD', 'entrytitle "MY-TITLE"');
Looks great @WarrenKuhfeld , this removed the 'product limit' part.
Could you please also help with the 'With number of subjects at risk' part? It is the title under the main title, obtained with asking for the numbers at risk (atrisk)
I have tired multiple combinations in vain:
_infile_ = tranwrd(_infile_, ' entrytitle "With Number of Subjects at Risk" ', 'entrytitle "testing" ');
_infile_ = tranwrd(_infile_, 'With Number of Subjects at Risk"', 'testing');
Solved
_infile_ = tranwrd(_infile_, 'entrytitle SECONDTITLE', 'entrytitle "MY SUBTITLE"');
Thanks @WarrenKuhfeld
Everything you need is working now, right?
There is nothing magical about any of this. You simply look at the template and then edit it. In the simplest case, you substitute one literal string for another. In your case, you substitute a literal string for a dynamic variable. Sometimes you add options or statements; sometimes you delete them. You can do all of this in an editor, but by using a DATA step, you have programmable/reproducible results.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.