plot of the odds ratios and their 95% confidence intervals created using SAS PROC SGPLOT,
but some of the tick values have been thinned. How plot the figure without remove or thinned tick values ?
Thanks a lot!
title "SGPLOT: Forest Plot";
proc sgplot data=excel_b;
scatter x=oddsratioest y=effect / xerrorlower=lowercl
xerrorupper=uppercl
markerattrs=or
(symbol=DiamondFilled size=5);
refline 1 / axis=x;
xaxis label="OR and 95% CI " min=0.9;
yaxis label="Covariates";
run;
With that many discrete vertical labels, there isn't enough room to plot them all without labels overlapping (which SGPLOT tries to avoid). You can
1. Decrease the font size for the tick values. Probably size=8 is about the smallest that can be read.
2. Increase the vertical size of the plot. Plots can stretch arbitrarily long.
3. Do both
To decrease the font size, use
YAXIS / valueattrs=(size=8);
To increase the vertical dimension of the graph, use the following BEFORE the call to PROC SGPLOT, For example:
ods graphics / width=500px height=800px;
Another option: Since you have two stages, you could use PROC SGPANEL to create a panel of plots, one for each stage.
With that many discrete vertical labels, there isn't enough room to plot them all without labels overlapping (which SGPLOT tries to avoid). You can
1. Decrease the font size for the tick values. Probably size=8 is about the smallest that can be read.
2. Increase the vertical size of the plot. Plots can stretch arbitrarily long.
3. Do both
To decrease the font size, use
YAXIS / valueattrs=(size=8);
To increase the vertical dimension of the graph, use the following BEFORE the call to PROC SGPLOT, For example:
ods graphics / width=500px height=800px;
Another option: Since you have two stages, you could use PROC SGPANEL to create a panel of plots, one for each stage.
Also, you can use FITPOLICY=none for the yaxis.
I have a similar problem with SGPLOT - it seems to ignore all my suggestions. I want an x axis with a format of monname1., i.e., JFMAMJJASOND, but with the code below (and variations) I always get this in the log, and an axis that shows "01Jan 01Feb 01Mar..."
ods graphics / width=1000px height=600px;
proc sgpanel data=work.mean_xyz;
where upcase(some_category) = "BLAHBLAH";
panelby product;
colaxis valuesformat=monname1. valueattrs=(size=8) fitpolicy=none;
rowaxis label="XYZ";
series x=obsdate y=model_xyz;
series x=obsdate y=act_xyz;
run;
NOTE: The column format YYMMDDD10 is replaced by an auto-generated format on the axis.
NOTE: Some of the tick values have been thinned.
I meant SGPANEL, not SGPLOT
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 25. Read more here about why you should contribute and what is in it for you!
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.