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
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
For #3
@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
Thank you! This worked to get what I needed to do. Appreciate your help.
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!
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.