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

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).

timesurv1surv2surv3surv4
01111
010.99363110.965475
110.98095510.954309
210.96836510.941546
310.96201710.931951
40.9906860.9620170.9891590.927144
50.9906860.9620170.9891590.922343
60.9813220.9556580.9571240.908054
70.9813220.9556580.9463940.900084
…………    
3450.6121250.7744570.5745680.592467
3500.6121250.7744570.5745680.590918
3550.6121250.7744570.5745680.589368
3560.6121250.7679910.5745680.589368
3600.6121250.7615240.5745680.589368
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.).

View solution in original post

5 REPLIES 5
FreelanceReinh
Jade | Level 19

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.).

Mingming1992
Calcite | Level 5

Thank you FreelanceReinhard. It helps a lot.

Norman21
Lapis Lazuli | Level 10

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;

Screenshot 2021-07-28 080726.png

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

Mingming1992
Calcite | Level 5

Thank you Norman21. It helps a lot.

ballardw
Super User

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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1421 views
  • 0 likes
  • 4 in conversation