BookmarkSubscribeRSS Feed
Ubai
Quartz | Level 8

Hi everyone,

 

I have three question about customizing the kaplan meier curve. I have read the "User’s Guide Customizing the Kaplan-Meier Survival Plot" and I have three questions.

 

1. How can I event probability in percent instead of values lower than 1? Can I using the template modification or format a value somewhere? I used to do this by exporting the survival plot data, formatting it, and then plotting it in SGPLOT.

 

2. Can I include the SurvivalTable in the kaplan-meier curve? I tried looking at the macro code, but I didn't find any place where I can modify it for such purpose

 

3. Can I add grids on the x or y axis?

 

4. When I try to delete the template the edited, I receive the following error message. I am using SAS Online Studio. Any ideas?

ERROR: Write access to member SASUSER.TEMPLAT.ITEMSTOR is denied.

 

Thanks in advance

9 REPLIES 9
WarrenKuhfeld
Rhodochrosite | Level 12

I can help you more on Monday when I am in the office.  I recently added an example somewhere that shows how to display percentages.  It might have been in that chapter or it might have been in my PharmaSUG submission for next year.  Either way, I can extract it and share it.


What is the SurvivalTable?  There are lots of examples of the at risk table.

 

You can change the macro variables (yoptions and xoptions)  to display grids.


Different installations and methods of running SAS have different permissions.  I have not heard about people having trouble deleting something in sasuser, but that does not mean much.  I can't help you much with that one.  There are ways to modify template search paths and make customized libraries that are well documented.  You can also store modified templates in Work.  I can easily help you with that when I am in the office on Monday.

Ubai
Quartz | Level 8

Thanks Warren for the quick response. Take your time.

 

For the survival table, I meant the external table with event information.

WarrenKuhfeld
Rhodochrosite | Level 12

If the graph on page 821 of https://support.sas.com/documentation/onlinedoc/stat/131/kaplan.pdf does not help, tell me more precisely what table you want displayed.  Remember, I am a graph and ODS guy (and a lot of other things), but I am not a researcher in health sciences, nor did I develop LIFETEST, so you have to explain it in concrete terms.

 

WarrenKuhfeld
Rhodochrosite | Level 12

The percentage example I have is for the failure plot.  It turns out that is the easier case.  What you need to do is plot a function of the original variables, eval(100 * original-var). You also need to change some ticks, and so on.  It is easier in the failure plot because there is already an eval(1-original-var), so you can make the change based on finding the "1-".  If you want to make the change to the survival plot, it will take some more work.  I'll post something more later.

WarrenKuhfeld
Rhodochrosite | Level 12

Here is how you can convert from proportions to percentages.  I use a DATA step to edit the template replacing each Y variable by an expression.  Furthermore, I replace the ticks, axis label, and maximum value on the Y axis. I also added grids.

ods graphics on;

proc template;
delete Stat.Lifetest.Graphics.ProductLimitSurvival;
source Stat.Lifetest.Graphics.ProductLimitSurvival / file='temp.tmp';
quit;

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

data _null_;
length var1 var2 $ 40;
infile 'temp.tmp' end=eof;
input;
if _n_ eq 1 then call execute('proc template;');
if left(_infile_) =: 'bandplot' then do;
var1 = scan(scan(_infile_, 2, '='), 1);
var2 = scan(scan(_infile_, 3, '='), 1);
put var1= var2=;
_infile_ = tranwrd(_infile_, trim(var1), cats('eval(100*',var1,')'));
_infile_ = tranwrd(_infile_, trim(var2), cats('eval(100*',var2,')'));
end;
if left(_infile_) =: 'scatterplot' or left(_infile_) =: 'stepplot' then do;
var1 = scan(scan(_infile_, 2, '='), 1);
put var1=;
_infile_ = tranwrd(_infile_, trim(var1), cats('eval(100*',var1,')'));
end;
_infile_ = tranwrd(_infile_, '0 .2 .4 .6 .8 1.0', '0 20 40 60 80 100');
_infile_ = tranwrd(_infile_, 'viewmax=1', 'viewmax=100');
_infile_ = tranwrd(_infile_, 'Survival Probability', 'Survival Percentage');
_infile_ = tranwrd(_infile_, 'yaxisopts=(', 'yaxisopts=(grid_display=on ');
call execute(_infile_);
if eof then call execute('quit;');
run;

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

  

Ubai
Quartz | Level 8

Hi @WarrenKuhfeld and thank you for the quick response.

 

1. I used to plot the survival curve in SGPlot before reading your chapter on customizing the kaplan-meier curve. I was able to present event probability in percent by just adding a format to the survival estimates data I get out of the PROC LIFETEST.

 

2. I can't try your solution. I am receiving the following error message when trying to delete the template, which is probably happening because I am using SAS Online Studio.

ERROR: Insufficient authorization to access /pbr/biconfig/940/Lev1/SASApp/temp.tmp.

 

3. The table I wanted to include inside my graph is the one you would get using the %SurvivalSummaryTable (i.e. from page 824). There is some space in my graph that allows the table to be included in the graph. I tried to solve this issue by expanding the  %macro StmtsBottom macro to include further variables, instead of manipulating the %survivalsummaryTable. However, I am receiving too many errors.

 

%macro StmtsBottom;
dynamic %do i = 1 %to 2; StrVal&i NObs&i NEvent&i %end;;
layout gridded / columns=7 border=TRUE autoalign=(TopRight);
entry ""; 
entry "Subjects"; 
entry "Event"; 
entry "Censored"; 
entry "Survival"; 
entry PctMedianConfid; 
entry halign=left "CL";
%do i = 1 %to 2;
%let t = / textattrs=GraphData&i;
entry halign=left Strval&i &t; 
entry NObs&i &t; 
entry NEvent&i &t; 
entry eval(NObs&i) &t;
entry eval(put(Median&i,&fmt)) &t;
entry eval(put(LowerMedian&i,&fmt)) &t;
entry eval(put(UpperMedian&i,&fmt)) &t;
%end;
endlayout;
%mend;

 

WarrenKuhfeld
Rhodochrosite | Level 12

http://go.documentation.sas.com/?docsetId=statug&docsetTarget=statug_ods_overview16.htm&docsetVersio...

http://go.documentation.sas.com/?docsetId=statug&docsetTarget=statug_ods_overview18.htm&docsetVersio...

 

See if either of these help.  What is your template search path?  Can you make it include work?  The links I include explain. Your template search path might be configured in some way other than the customary default.  I can look at what you submitted in more detail later, but I have to be somewhere soon.

Ubai
Quartz | Level 8
 61         ods path show;
 Current ODS PATH list is: 
 
 1. WORK.TEMPLAT(UPDATE) 
 2. SASUSER.TEMPLAT(READ) 
 3. SASHELP.TMPLMST(READ) 

and when I try to delete the template 

 60         proc template;
 61          delete Stat.Lifetest.Graphics.ProductLimitSurvival;
 WARNING: Path 'Stat.Lifetest.Graphics.ProductLimitSurvival' does not exist!
 NOTE: Could not delete 'Stat.Lifetest.Graphics.ProductLimitSurvival' from template store!
 62          source Stat.Lifetest.Graphics.ProductLimitSurvival / file='Lifetest.tmp';
 ERROR: Insufficient authorization to access /pbr/biconfig/940/Lev1/SASApp/Lifetest.tmp.
WarrenKuhfeld
Rhodochrosite | Level 12

I run under a Unix system where I can create a file like that.  File access, creation, permissions, directories, etc. can vary substantially from one system to another.  It appears that your default working directory is not someplace to which you can write.  Do you have any other examples where you have used SAS to make a file?  Can you follow the lead of those?  Maybe use a C: path if you are on Windows.  There are many people in SAS Communities who can speak more intelligently than me about how you should specify a path to create a file.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1569 views
  • 3 likes
  • 2 in conversation