BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lavienrose1
Calcite | Level 5

Hi

 

I am a beginner at SAS - I have produced a KM curve but having trouble editing the axes. 

 

I used the code below:

ODS graphics on;
ODS select survivalplot(persist) failureplot(persist);

PROC lifetest data=solo2_date plots=survival (test atrisk (maxlen=8 outside (0.15)));
Time ttpfs*pfs(0);
strata randtrt;
run;

ODS graphics off;

 

It gives me the KM curve but I would like to edit :

  • y axis - instead of 0.0 to 1.0 in increments of 0.2 , i would like 0 to 100 in increments of 20 (%)
  • x axis - instead of days 0 to 1000 in increments of 200 I would like in months in increments of 3

I've tried reading other posts and guides but just not getting it right. Any help appreciated, thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Rather than changing from 0 to 100 see if you can apply a percent formst to the 0 to 1 scale. 

View solution in original post

2 REPLIES 2
lavienrose1
Calcite | Level 5

Hi,

 

I've figured how to edit the x and y axis to my liking (coding below). By changing the y axis scale from 0 to 100 (%) rather than 0 to 1, the curves do not correspondingly 'resize' to the 0 to 100 scale so appears as a flat line...how do I rectify this?

 

data solo2_date;
set solo2_date;
ttpfsmo=ttpfs/30.5;
run;

ODS graphics on;
ods trace output;
proc lifetest data=solo2_date;
time ttpfsmo*pfs(0);
strata randtrt;
run;

ODS trace off;

proc template;
source Stat.Lifetest.Graphics.ProductLimitSurvival;
run;

options ls=95;
data _null_;
infile 'http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/templft2.html'
device=url;
retain pre 0;
input;
if index(_infile_, '</pre>') then pre = 0;
if pre then put _infile_;
if index(_infile_, '<pre>') then pre = 1;
run;

data _null_;
infile 'http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/templft2.html'
device=url;
file 'junk.junk';
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 'junk.junk' / nosource;

%SurvivalTemplateRestore
%SurvivalTemplate

proc template;
delete Stat.Lifetest.Graphics.ProductLimitSurvival / store=sasuser.templat;
delete Stat.Lifetest.Graphics.ProductLimitSurvival2 / store=sasuser.templat;
run;

/* Make the macros and macro */
%SurvivalTemplateRestore /* variables available */
%let TitleText0 = "Kaplan-Meier Plot"; /* Change the title. */
%let TitleText1 = &titletext0 " for " STRATUMID;
%let TitleText2 = &titletext0;
%SurvivalTemplate /* Compile the templates with */
/* the new title. */
proc lifetest data=solo2_date /* Perform the analysis and make */
plots=survival(cb=hw test); /* the graph. */
time ttpfsmo*pfs(0);
strata randtrt;
run;
%SurvivalTemplateRestore /* Restore the default macros */
/* and macro variables. */
proc template; /* Restore the default templates. */
delete Stat.Lifetest.Graphics.ProductLimitSurvival / store=sasuser.templat;
delete Stat.Lifetest.Graphics.ProductLimitSurvival2 / store=sasuser.templat;
run;

%SurvivalTemplateRestore
%let yOptions = label="Progression-free survival (%%)"
linearopts=(viewmin=0 viewmax=100
tickvaluelist=(0 10 20 30 40 50 60 70 80 90 100));
%let xOptions= label="Time since randomisation (months)"
linearopts=(viewmin=0 viewmax=36
tickvaluelist=(0 3 6 9 12 15 18 21 24 27 30 33 36));
%SurvivalTemplate

proc lifetest data=solo2_date plots=survival (test atrisk (maxlen=8 outside (0.15)));
time ttpfsmo*pfs(0);
strata randtrt;
run;

Reeza
Super User

Rather than changing from 0 to 100 see if you can apply a percent formst to the 0 to 1 scale. 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

What is ANOVA?

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.

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