Dear SAS users,
I am trying to make a graph with a break on the Y axis. I am analyzing costs subdivided by different categories. The x axis is discrete and shows a scatter with the mean for each group of observations.
I have used ranges but it does not work. I receive this error: "ERROR 79-322: Expecting a -."
I am using the SAS 9.4 version. Could anybody please let me know what am I doing wrong?
Thank you.
proc means data=wneuro9 (where=(DMF ne '' AND Admgroup =0)) mean noprint;
class DMF;
var ACT_TOTAL_COSTad;
output out= costmean(where=(_type_ eq 1) rename=(DMF=GPRG))
mean = mean ;
run;
data combined;
format Mean 6. ;
set costmean(keep=GPRG mean) wneuro9(where=(DMF ne '') keep=DMF ACT_TOTAL_COSTad);
run;
ods graphics / reset width=5in height=3in ;
proc sgplot data=combined noborder noautolegend;
styleattrs axisbreak=bracket;
scatter x=dmf y=ACT_TOTAL_COSTad / jitter clusterwidth=0.8
markerattrs=(symbol=plus size=5) transparency=0.8;
yaxis ranges=(min - 60000 230000 - max);
highlow x=GPRG low=mean high=mean / nofill type=bar barwidth=0.4;
xaxis type=discrete labelattrs=(size=9) display=(noline noticks nolabel);
yaxis ranges=(min - 60000 230000 - max)labelattrs=(size=9) display=(noline noticks) grid label='COST';
run;
The AXISBREAK option is availabe as of SAS 9.4 TS1M3 -> is your version TS1M3 or higher?
If not, that means it will not work.
Are you intending to have two YAXIS statements as well?
@Giampaolo wrote:
Hi Reeza,
Apologies for making it more difficult, here is the log.
Thank you
Giampaolo
Post the log please, it usually indicates where the error is.
Hi Reeza,
Apologies for making it more difficult, here is the log.
Thank you
Giampaolo
The AXISBREAK option is availabe as of SAS 9.4 TS1M3 -> is your version TS1M3 or higher?
If not, that means it will not work.
Are you intending to have two YAXIS statements as well?
@Giampaolo wrote:
Hi Reeza,
Apologies for making it more difficult, here is the log.
Thank you
Giampaolo
proc product_status;run;
So your version does not support the AXISBREAK option, so you need to remove it for now and try your code again.
Personally, for developing SAS graphs, start with the minimal necessary code, just your scatter and plot statements first. Then start adding the options to make it look good after you've verified your data is plotting correctly.
Yes the data plotted correctly when I did not attempt breaking the Y axis.
So is there a solution for previous SAS versions? Do I need to change the template?
The axis will break, you don't have control over how it looks though.
@Giampaolo wrote:
Yes the data plotted correctly when I did not attempt breaking the Y axis.
So is there a solution for previous SAS versions? Do I need to change the template?
I included two YAXIS statement because I thought that having scatter and highlow superimposed would require adjusting the axis twice. I did not have the chance to verify if this was correct because I did not get any output both with one and two YAXIs statements
Only one YAXIS or XAXIS will apply so having multiple statements is not needed and may result in the procedure not using the "best" one.
If you want a separate appearing axis a YAXIS2 or XAXIS2 to show a different axis on the other side of the graph with different options may be appropriate.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.