BookmarkSubscribeRSS Feed
dr2014
Quartz | Level 8

Hi all,

I need advice on how to "plot lines for multiple groups within a sas variable". I used proc lifetest to get output dataset and used proc gplot to produce an rtf file.

 

proc lifetest data= abc method=KM outsurv=xyz plot=(s); time duration*censor (1,2);
strata group ; run;

 

The variable "group" has "6 categories" and proc gplot gives me plot points by default so I used symbol statement with i=spline option, but it gave me a line graph for only one group

 

Here is the code:

proc gplot data = xyz;
symbol1 i=spline;
plot survival*duration= group / vaxis=axis1 haxis=axis2 legend=legend1;;
run;

 

How can I get line graphs for all the categories within the group? Thanks.

 

 

 

 

3 REPLIES 3
Reeza
Super User
I would recommend using SGPLOT instead of GPLOT to graph your data. SG procedures produce higher quality graphics, is simpler to code IMO, and have more options to customize your graphics.

Here's some examples of SGPLOT code and survival curves
https://blogs.sas.com/content/graphicallyspeaking/2018/02/19/survival-plot-twist-using-sgplot-proced...
dr2014
Quartz | Level 8
Thank you for the recommendation.
Rick_SAS
SAS Super FREQ

If you submit

ODS GRAPHICS ON;

before your PROC LIFETEST call, the procedure should produce a survival plot automatically. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1814 views
  • 1 like
  • 3 in conversation