BookmarkSubscribeRSS Feed
SeaMoon_168
Quartz | Level 8

I use Proc Lifetest to create KM curves by using SAS macro but I cannot find a easy way to make x-axis and y-axis meet at (0,0) to the bottom left corner using lifetest and sas macro. I would not use sgplot to make it. Many thanks.

 

Figure found onlineFigure found online

7 REPLIES 7
WarrenKuhfeld
Ammonite | Level 13

https://support.sas.com/documentation/onlinedoc/stat/151/kaplan.pdf

Search for

%let yoptions=

and 

%let xoptions=.

You will see several examples and general info.

Next, look at page 899.

Now try to modify the example to specify offsetmin= instead of the options in that example.

SeaMoon_168
Quartz | Level 8

Thank you for your reply. 

I added offsetmin=0 to xOptions and yOptions. Then y-axis starts from 0 a the bottom left corner but x-axis still does Not start from 0 (shown below). 

 

sample.png

mtnbikerjoshua
Obsidian | Level 7

Hi @SeaMoon_168,

 

The following code, copied right out of the guide linked by @WarrenKuhfeld, works for me in SAS Enterprise Guide 7.15 HF8 (7.100.5.6214) (32-bit). If it still isn't working for you, you might need to provide more details.

 

ods graphics on;


data _null_;
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/151;
infile "http:&url/templft.html" device=url;
file 'macros.tmp';
retain pre 0;
input;
_infile_ = tranwrd(_infile_, '&', '&');
_infile_ = tranwrd(_infile_, '&lt;' , '<');
if index(_infile_, '</pre>') then pre = 0;
if pre then put _infile_;
if index(_infile_, '<pre>') then pre = 1;
run;
%inc 'macros.tmp' / nosource;


%ProvideSurvivalMacros

%let yOptions = offsetmin=0;
%let xOptions = offsetmin=0;

%CompileSurvivalTemplates

proc lifetest data=sashelp.BMT plots=survival(cb=hw test) notable;
  time T * Status(0);
  strata Group;
run;

That code produces the following output.

 

mtnbikerjoshua_2-1651601773601.png

SeaMoon_168
Quartz | Level 8

Thank you for your reply. Shall I just copy and use the same code between "ods graphics on;" and "%CompileSurvivalTemplates" without any changes? But it does not work ...

 

mtnbikerjoshua
Obsidian | Level 7
Can you post example code that will reproduce the problem?
SeaMoon_168
Quartz | Level 8

Here is my code with adding your code at the beginning. Thanks.

ods graphics on;


data _null_;
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/151;
infile "http:&url/templft.html" device=url;
file 'macros.tmp';
retain pre 0;
input;
_infile_ = tranwrd(_infile_, '&amp;', '&');
_infile_ = tranwrd(_infile_, '&lt;' , '<');
if index(_infile_, '</pre>') then pre = 0;
if pre then put _infile_;
if index(_infile_, '<pre>') then pre = 1;
run;
%inc 'macros.tmp' / nosource;

 

%inc "D:\XXX\KMmacros.sas";


%ProvideSurvivalMacros
%let LegendOpts = ;

%let tatters = textattrs=(size=12pt family='Times New Roman');
%let TitleText0 = "XXX"; 
%let TitleText1 = &titletext0 " for " STRATUMID/&tatters;
%let TitleText2 = &titletext0/&tatters;
%let ntitles=1;


%let yOptions = offsetmin=0
label="XXX"
labelattrs=(size=12pt family='Times New Roman')
tickvalueattrs=(size=12pt family='Times New Roman')
linearopts=(viewmin=0 viewmax=1
tickvaluelist=(0 .2 .4 .6 .8 1));

 

%let xOptions = offsetmin=0
shortlabel=XNAME
labelattrs=(size=12pt family='Times New Roman')
tickvalueattrs=(size=12pt family='Times New Roman')
linearopts=(viewmin=0 viewmax=2
tickvaluelist=(0 .5 1 1.5 2));

 

%let AtRiskOpts = labelattrs=(family='Times New Roman' size=12pt)
valueattrs=(family='Times New Roman' size=12pt);

%CompileSurvivalTemplates

mtnbikerjoshua
Obsidian | Level 7

Apologies for not responding. I ran your code with the following proc lifetest at the end, and the axes still came out as desired. Did you ever figure out the issue?

 

data toplot;
  set sashelp.BMT;
  T = T / 200;
run;

proc lifetest data=toplot plots=survival(cb=hw test) notable;
  time T * Status(0);
  strata Group;
run;

 

mtnbikerjoshua_1-1668787123215.png

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 7 replies
  • 1840 views
  • 2 likes
  • 3 in conversation