I have run SGPLOT with “Series” and “Scatter” but can’t seem to get the y-axis values to be explicit value (i.e., 50 to 100 by 10). Tried multiple different options including “yaxis type=linear values=(50 to 100 by 10);” and “yaxis min=50 max=100;” and neither worked (see SAS code and log below)
I have also provided the output.
How can I explicitly set the y-axis values in this scenario?
data forplot;
trt_num = 10;
xval=1;
aval_mean = 65;
aval_lclm = 61;
aval_uclm = 69;
output;
xval=10;
aval_mean = 65;
aval_lclm = 61;
aval_uclm = 69;
output;
xval=15;
aval_mean = 65;
aval_lclm = 61;
aval_uclm = 69;
output;
xval=22;
aval_mean = 65;
aval_lclm = 61;
aval_uclm = 69;
output;
trt_num = 20;
xval=1;
aval_mean = 75;
aval_lclm = 71;
aval_uclm = 79;
output;
xval=10;
aval_mean = 75;
aval_lclm = 71;
aval_uclm = 79;
output;
xval=15;
aval_mean = 75;
aval_lclm = 71;
aval_uclm = 79;
output;
xval=22;
aval_mean = 75;
aval_lclm = 71;
aval_uclm = 79;
output;
run;
title "Attempt #1";
proc sgplot data=forplot;
scatter x=xval y=aval_mean /
yerrorlower=aval_lclm yerrorupper=aval_uclm group=trt_num
markerattrs=(symbol=SquareFilled size=15px);
series x=xval y=aval_mean / group=trt_num legendlabel="Means";
styleattrs datacontrastcolors = (red blue green purple) ;
yaxis values=(50 to 100 by 10);
yaxis label= 'Y-axis';
xaxis type=linear values=(0 to 25 by 5) offsetmin=0.1 offsetmax=0.1;
xaxis label= "X-axis";
run;
quit;
title "Attempt #2";
proc sgplot data=forplot;
scatter x=xval y=aval_mean /
yerrorlower=aval_lclm yerrorupper=aval_uclm group=trt_num
markerattrs=(symbol=SquareFilled size=15px);
series x=xval y=aval_mean / group=trt_num legendlabel="Means";
styleattrs datacontrastcolors = (red blue green purple) ;
yaxis min=50 max=100;
yaxis label= 'Y-axis';
xaxis type=linear values=(0 to 25 by 5) offsetmin=0.1 offsetmax=0.1;
xaxis label= "X-axis";
run;
quit;
yaxis values=(50 to 100 by 10) label= 'Y-axis';
xaxis type=linear values=(0 to 25 by 5) offsetmin=0.1 offsetmax=0.1 label= "X-axis";
Your use of two YAXIS/XAXIS statements is the problem combine them.
yaxis values=(50 to 100 by 10) label= 'Y-axis';
xaxis type=linear values=(0 to 25 by 5) offsetmin=0.1 offsetmax=0.1 label= "X-axis";
Your use of two YAXIS/XAXIS statements is the problem combine them.
I would have expected it to work. Many other statements work that way but i'm thinking of proc report DEFINE, or CLASS statement in PROC SUMMARY.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.