Hello all, I was hoping to find some help regarding this dataset. I want to drew survival curves by SAS based on it but I do not know how to do it. I am sure this would be a simple resolution for someone with more experience utilizing SAS. Any help would be very much appreciated. Thank you!
Here is the dataset:(Number in the column blow each surv means the Survival Probability on these time (days).
time | surv1 | surv2 | surv3 | surv4 |
0 | 1 | 1 | 1 | 1 |
0 | 1 | 0.993631 | 1 | 0.965475 |
1 | 1 | 0.980955 | 1 | 0.954309 |
2 | 1 | 0.968365 | 1 | 0.941546 |
3 | 1 | 0.962017 | 1 | 0.931951 |
4 | 0.990686 | 0.962017 | 0.989159 | 0.927144 |
5 | 0.990686 | 0.962017 | 0.989159 | 0.922343 |
6 | 0.981322 | 0.955658 | 0.957124 | 0.908054 |
7 | 0.981322 | 0.955658 | 0.946394 | 0.900084 |
………… | ||||
345 | 0.612125 | 0.774457 | 0.574568 | 0.592467 |
350 | 0.612125 | 0.774457 | 0.574568 | 0.590918 |
355 | 0.612125 | 0.774457 | 0.574568 | 0.589368 |
356 | 0.612125 | 0.767991 | 0.574568 | 0.589368 |
360 | 0.612125 | 0.761524 | 0.574568 | 0.589368 |
Hello @Mingming1992,
I would start with a basic step plot:
proc sgplot data=have;
step x=time y=surv1;
step x=time y=surv2;
step x=time y=surv3;
step x=time y=surv4;
run;
Next, there are a lot of options to modify the plot (like line types and colors, axis labels, tick marks, the legend, etc.).
Hello @Mingming1992,
I would start with a basic step plot:
proc sgplot data=have;
step x=time y=surv1;
step x=time y=surv2;
step x=time y=surv3;
step x=time y=surv4;
run;
Next, there are a lot of options to modify the plot (like line types and colors, axis labels, tick marks, the legend, etc.).
Thank you FreelanceReinhard. It helps a lot.
Following on from the idea of FreelanceReinhard and using the code from one of Sanjay Matange's blogs (https://blogs.sas.com/content/graphicallyspeaking/2018/02/19/survival-plot-twist-using-sgplot-proced...) you can produce something like this:
title 'Product-Limit Survival Estimates';
footnote j=l h=6pt italic 'This visual is for discussion of graph features only.'
' The actual details should be customized by user to suit their application.';
data my;
input time surv1 surv2 surv3 surv4 ;
label
time='Survival Time (days)'
surv1='Group 1'
surv2='Group 2'
surv3='Group 3'
surv4='Group 4'
;
cards;
0 1 1 1 1
0 1 0.993631 1 0.965475
1 1 0.980955 1 0.954309
2 1 0.968365 1 0.941546
3 1 0.962017 1 0.931951
4 0.990686 0.962017 0.989159 0.927144
5 0.990686 0.962017 0.989159 0.922343
6 0.981322 0.955658 0.957124 0.908054
7 0.981322 0.955658 0.946394 0.900084
345 0.612125 0.774457 0.574568 0.592467
350 0.612125 0.774457 0.574568 0.590918
355 0.612125 0.774457 0.574568 0.589368
356 0.612125 0.767991 0.574568 0.589368
360 0.612125 0.761524 0.574568 0.589368
;
proc sgplot data=my noborder;
step x=time y=surv1 / ;
step x=time y=surv2 / ;
step x=time y=surv3 / ;
step x=time y=surv4 / ;
run;
Thank you Norman21. It helps a lot.
If you use one of the several SAS procedures such as Lifereg, Lifetest or Phreg to create the survival probabilities from "raw" data, they have a number of Plot options available.
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!
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.
Ready to level-up your skills? Choose your own adventure.