BookmarkSubscribeRSS Feed
gunnerhenry
Calcite | Level 5

I'm trying to get "observed survival curves" from standard Kaplan Meier curve using PROC LIFETEST and "Expected or Predicted Survival curve" using PROC PHREG in the same graph. Can anyone help me how to do this. I'm using base SAS 9.4 but have access to the whole SAS suite if needed.

 

"Predicted survival" code

 

proc phreg data = mydata plots(overlay)=survival;
model time*event(0) = Age HTN platelets/ rl ties = efron;
baseline out = pred1 survival = _all_ ;
run;

 

"Observed survival" code

 

proc lifetest data=mydata outsurv=km1 plots=s;
time time*event(0);
run;

 

Thanks

 

 

 

 

 

 

2 REPLIES 2
Reeza
Super User

To do this you need to capture the raw data used to create the curves and then plot them on your own. Fortunately this is relatively easy. 

 

1. Capture output from each proc

2. Merge or append the data sets 

3. Plot using SGPLOT - use two different STEP statements so it doesn't matter too much how the merge happens. 

 

For #1

https://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html

 

For #2

https://video.sas.com/detail/video/4572997800001/merging-sas-tables-in-a-data-step?autoStart=true&q=...

 

For #3

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

 


@gunnerhenry wrote:

I'm trying to get "observed survival curves" from standard Kaplan Meier curve using PROC LIFETEST and "Expected or Predicted Survival curve" using PROC PHREG in the same graph. Can anyone help me how to do this. I'm using base SAS 9.4 but have access to the whole SAS suite if needed.

 

"Predicted survival" code

 

proc phreg data = mydata plots(overlay)=survival;
model time*event(0) = Age HTN platelets/ rl ties = efron;
baseline out = pred1 survival = _all_ ;
run;

 

"Observed survival" code

 

proc lifetest data=mydata outsurv=km1 plots=s;
time time*event(0);
run;

 

Thanks

 

 

 

 

 

 


 

 

gunnerhenry
Calcite | Level 5

Thank you! This worked to get what I needed to do. Appreciate your help.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1486 views
  • 2 likes
  • 2 in conversation