Programming the statistical procedures from SAS

How to edit x and y axis of a KM curve

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 18
Accepted Solution

How to edit x and y axis of a KM curve

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.


Accepted Solutions
Solution
‎05-07-2018 07:22 PM
Super User
Posts: 23,776

Re: How to edit x and y axis of a KM curve

Posted in reply to lavienrose1

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


All Replies
Occasional Contributor
Posts: 18

Re: How to edit x and y axis of a KM curve

Posted in reply to lavienrose1

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;

Solution
‎05-07-2018 07:22 PM
Super User
Posts: 23,776

Re: How to edit x and y axis of a KM curve

Posted in reply to lavienrose1

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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