BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RAVI2000
Lapis Lazuli | Level 10

Hello Everyone,

 

I have created a survival graph with multiple groups as below.

S_RAVI_0-1635478381326.png

As you look here it is a bit clustered at the top of the graph. 

Is there any procedure or way to zoom the graph? so can analyze properly.

ODS PDF file='survival_Ethnicity white race by SES.pdf';
ods graphics on / imagefmt=png imagename= "Surival for Ethnicity by White Race and SES";
proc lifetest data = adsl3 method=KM plots=s(test) 
		timelist = 0 1 2 5 10 15 20 25 30 CONFTYPE= linear;
	time Years*death(0);
	strata race_ses_white;
title1 "Overall Survival Ethnicity by White Race by SES";
run ;
1 ACCEPTED SOLUTION

Accepted Solutions
djrisks
Barite | Level 11

Hi @RAVI2000,

 

Perhaps you can use the MIN option in the YAXIS statement to make the graph go from 0.4 to 1.

 

Please see the example below:

options nodate nonumber; 
ods escapechar='^';
ods listing close;
ods graphics on;
ods output survivalplot = sj.survplot;
proc lifetest data = sj.adsl3 method = km plots=s(test) 
		timelist = 0 1 2 5 10 15 20 25 30 conftype = linear;
	time years * death(0);
	strata ses;
run;


ods tagsets.rtf file = "/home/Projects/programs/exhibit_01.rtf";
ods graphics on / height = 8in width = 9in;
title1 j=c h=12pt font = arial "Overall Survival by SES";

proc sgplot data = sj.survplot;
		step x=time y=survival /group=stratum name='s' lineattrs=(pattern=solid);
	xaxis label="Years" values=(0 to 5 by 1);
	yaxis label="Survival Probability" values=(0.4 to 1 by 0.2);
	scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
	scatter x=time y=censored / markerattrs=(symbol=plus) group=stratum;
	keylegend 'c'/location=inside position=topright;
	keylegend 's'/location=inside position=bottomleft;
run; 

ods tagsets.rtf close;
ods listing;

 

View solution in original post

12 REPLIES 12
whymath
Lapis Lazuli | Level 10
height= option at ods graphics can modify the height of graph.
And locate the legend at right bottom inside the axis area may helps, too.
ballardw
Super User

May also want to set the graph to make a wider display using Ods graphics /width = <something>.

 

Or create a data set and use that data for SGPLOT where you can apply more controls.

RAVI2000
Lapis Lazuli | Level 10

options nodate nonumber; 
ods escapechar='^';
ods listing close;
ods graphics on;
ods output survivalplot = sj.survplot;
proc lifetest data = sj.adsl3 method = km plots=s(test) 
		timelist = 0 1 2 5 10 15 20 25 30 conftype = linear;
	time years * death(0);
	strata ses;
run;


ods tagsets.rtf file = "/home/Projects/programs/exhibit_01.rtf";
ods graphics on / height = 8in width = 9in;
title1 j=c h=12pt font = arial "Overall Survival by SES";

proc sgplot data = sj.survplot;
		step x=time y=survival /group=stratum name='s' lineattrs=(pattern=solid);
	xaxis label="Years" values=(0 to 5 by 1);
	yaxis label="Survival Probability" values=(0 to 1 by 0.2);
	scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
	scatter x=time y=censored / markerattrs=(symbol=plus) group=stratum;
	keylegend 'c'/location=inside position=topright;
	keylegend 's'/location=inside position=bottomleft;
run; 

ods tagsets.rtf close;
ods listing;

I have given height and width option in ODS but still not getting desired output zoomed.

S_RAVI_0-1635880000129.png

I still feel the graph is clustered. Any other options @ballardw @Ksharp @whymath ? Thankyou!

 

djrisks
Barite | Level 11

Hi @RAVI2000,

 

Perhaps you can use the MIN option in the YAXIS statement to make the graph go from 0.4 to 1.

 

Please see the example below:

options nodate nonumber; 
ods escapechar='^';
ods listing close;
ods graphics on;
ods output survivalplot = sj.survplot;
proc lifetest data = sj.adsl3 method = km plots=s(test) 
		timelist = 0 1 2 5 10 15 20 25 30 conftype = linear;
	time years * death(0);
	strata ses;
run;


ods tagsets.rtf file = "/home/Projects/programs/exhibit_01.rtf";
ods graphics on / height = 8in width = 9in;
title1 j=c h=12pt font = arial "Overall Survival by SES";

proc sgplot data = sj.survplot;
		step x=time y=survival /group=stratum name='s' lineattrs=(pattern=solid);
	xaxis label="Years" values=(0 to 5 by 1);
	yaxis label="Survival Probability" values=(0.4 to 1 by 0.2);
	scatter x=time y=censored / markerattrs=(symbol=plus) name='c';
	scatter x=time y=censored / markerattrs=(symbol=plus) group=stratum;
	keylegend 'c'/location=inside position=topright;
	keylegend 's'/location=inside position=bottomleft;
run; 

ods tagsets.rtf close;
ods listing;

 

JeffMeyers
Barite | Level 11
To add to this you might want to turn off the censor markers (not plot the SCATTER statements above). Your graphs have a lot of censor indicators making the lines into what Dr. Therneau would call "Wooly Bear" lines. If you remove them it will be easier to see the lines for comparison and they aren't adding much information to the plot currently.
RAVI2000
Lapis Lazuli | Level 10
I wonder I cannot remove the censor as this is a Spatial data analysis. I have a lot of data. Please correct me.
JeffMeyers
Barite | Level 11
I don't think they add much information to the plot and make the lines hard to read. Another option you can do is to add a Number of cumulative censors to the bottom of the graph (like a patient's at risk type of table) if you want to keep track of where and how many censors have occurred.
RAVI2000
Lapis Lazuli | Level 10
Hello @djrisks,

Can you convert this into a macro to generate multiple outputs? meaning how can I give multiple destination files?

Thanks!
Ksharp
Super User
Maybe could try this :

yaxis label="Survival Probability" values=(0.5 to 1 by 0.1);
JeffMeyers
Barite | Level 11
Nice to see a shout out to my macro. @RAVI2000 if you want to try using it feel free to ask me any questions you may have.
Ksharp
Super User
Your macro is awesome . The problem I meet is can't display Chinese . and I have to use option FONTFAMILY= 宋体 to display Chinese characters .

And I need change "+ Censored" in legend into Chinese "+ 删失" .and I have to modify your macro original code to get that .

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 12 replies
  • 2347 views
  • 2 likes
  • 6 in conversation