BookmarkSubscribeRSS Feed
TL93
Obsidian | Level 7

Hello everyone! How can I smooth my Kaplan-Meier curves in SAS?

 

Context: I am releasing results from a research center. According to their rules, every "step" in the Kaplan-Meier curve needs to have at least X number of respondents. Mine does not meet this requirement so I must smooth out the curve and eliminate the jagged "steps."

 

Here is my syntax for the Kaplan-Meier curves

proc lifetest data=cancer.modelone method=km plots=survival cs=none notable;
time duration*cancer(0);
strata sex;
symbol1 V=none color=blue line=1;
symbol2 v=none color=red line=1;
title1 font="Arial 11pt" Height=1 Bold 'KM Curve by Sex';
run;

Below is an illustration of what I want. I found these examples online but they are STATA outputs (STATA uses Lowess Smoothing ?? - I'm not familiar with STATA).

smooth km curves.png

 

I am also not familiar with Macros or SQL. Thank you for your time!

3 REPLIES 3
Reeza
Super User
You can get the output from the PROC LIFETEST and then apply a LOESS statement within SGPLOT to plot the data instead of using the default SAS output.
TL93
Obsidian | Level 7

Can I apply LOESS to GPLOT?

 

I have used proc gplot because I wanted to adjust the x and y axis of the Kaplan-Meier figure. I got the output from PROC LIFETEST and used PROC GPLOT as shown:

proc lifetest data=cancer.modelone outsurv=kmgender noprint;
time duration*cancer(0);
strata sex;
symbol1 V=none color=blue line=1;
symbol2 v=none color=red line=2;
title1 font="Arial 11pt" Height=1 Bold 'KM Curve by Sex';
run;

goption reset=all ftext=simplex;
symbol1 line=1 color=blue i=stepj;
symbol2 line=1 color=red i=stepj;
axis1 label=(angle=90 'Survival Probability') order=(0.70 to 1 by .02);
axis2 label=('Time to Cancer Diagnosis (days)') order=(0 to 7875 by 1125);

proc gplot data=cancer.kmgender;
plot survival*duration=sex /vaxis=axis1 haxis=axis2;
title 'Kaplan-Meier Curve by Sex';
run;

What would the syntax look like with the LOESS statement?

 

Thank you!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1621 views
  • 0 likes
  • 2 in conversation