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

Hi all,

 

I'm looking to make some modifications to a Kaplan-Meier survival curve (I work in SAS version 9.4). I'm somewhat familiar with using the SAS KM macros, however I am struggling with modifying the summary table options that I'm interested in producing. Namely, I'd like both the annual # of events and corresponding # of participants still at risk to print at the bottom of the figure (as shown in the attached documents).

 

I've attached the following: a) My current Kaplan-Meier curve output; b) my corresponding code; and c) the figure I am trying to emulate.

 

Thanks in advance for your assistance!

 

 

 

 

SAS Survival Plot.JPG

 

%ProvideSurvivalMacros
%let TitleText0 = "Figure 5. Kaplan-Meier plot of the unadjusted cumulative incidence of hypertension according to categories of baseline walking amount";
%let TitleText1 = &titletext0 " for " STRATUMID;
%let TitleText2 = &titletext0;
%let StepOpts = lineattrs=(thickness=2);
%let GraphOpts = DataContrastColors=(red cx9D3CDB green blue)
DataColors=(cx9D3CDB red green blue);
%let yOptions = label = "Cumulative Incidence (%)";
%let xOptions = label = "Follow-up Time (years)";
%let ntitles = 1;
%let GraphOpts = DesignHeight=500px;
%let LegendOpts = title=GROUPNAME location=inside across=1 autoalign=(bottomleft);
%CompileSurvivalTemplates

ods graphics on;
proc lifetest data=temp plot=s(nocensor test atrisk(MAXLEN=50 outside(0.15))) notable; 
time timeyr*F33PILLSHYP(0); 
strata walk_cat / order=internal;  
format walk_cat walk_catf.; 
label walk_cat="MET-hr/week:";
run;

 

 

JACC fig.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Did a quick check, it does look like a second xaxistable seems to work as expected. That makes it pretty straightforward.

View solution in original post

3 REPLIES 3
Reeza
Super User

You likely need to get into template modification for this type of graph. Or...catpure the data and use SGPLOT instead as a starter. I would probably recommend the latter. First get the data and then follow some blog posts (I'll post links in a minute) to get your graphs. Then copy the template for the graph and modify that.

EDIT: looks like there may be an easier way, you still need to capture the data, but then you can use the xaxistable statement twice and see how that works. 

 

https://blogs.sas.com/content/graphicallyspeaking/2018/02/19/survival-plot-twist-using-sgplot-proced...

 

If you're still having trouble, post back and someone can help with the code. You posted your code which is good, but we can't run it so not as helpful as if you used a data set that everyone has access to, ie from sashelp. 

 


@Cmill555 wrote:

Hi all,

 

I'm looking to make some modifications to a Kaplan-Meier survival curve (I work in SAS version 9.4). I'm somewhat familiar with using the SAS KM macros, however I am struggling with modifying the summary table options that I'm interested in producing. Namely, I'd like both the annual # of events and corresponding # of participants still at risk to print at the bottom of the figure (as shown in the attached documents).

 

I've attached the following: a) My current Kaplan-Meier curve output; b) my corresponding code; and c) the figure I am trying to emulate.

 

Thanks in advance for your assistance!

 

 

 

 

SAS Survival Plot.JPG

 

%ProvideSurvivalMacros
%let TitleText0 = "Figure 5. Kaplan-Meier plot of the unadjusted cumulative incidence of hypertension according to categories of baseline walking amount";
%let TitleText1 = &titletext0 " for " STRATUMID;
%let TitleText2 = &titletext0;
%let StepOpts = lineattrs=(thickness=2);
%let GraphOpts = DataContrastColors=(red cx9D3CDB green blue)
DataColors=(cx9D3CDB red green blue);
%let yOptions = label = "Cumulative Incidence (%)";
%let xOptions = label = "Follow-up Time (years)";
%let ntitles = 1;
%let GraphOpts = DesignHeight=500px;
%let LegendOpts = title=GROUPNAME location=inside across=1 autoalign=(bottomleft);
%CompileSurvivalTemplates

ods graphics on;
proc lifetest data=temp plot=s(nocensor test atrisk(MAXLEN=50 outside(0.15))) notable; 
time timeyr*F33PILLSHYP(0); 
strata walk_cat / order=internal;  
format walk_cat walk_catf.; 
label walk_cat="MET-hr/week:";
run;

 

 

JACC fig.JPG


 

 

Reeza
Super User
Did a quick check, it does look like a second xaxistable seems to work as expected. That makes it pretty straightforward.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1665 views
  • 0 likes
  • 2 in conversation