BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
jimmac01
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
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.

View solution in original post

3 REPLIES 3
data_null__
Jade | Level 19
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.

jimmac01
Calcite | Level 5
Wow, thanks I am embarrassed for not catching this myself.
data_null__
Jade | Level 19

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 3 replies
  • 1105 views
  • 4 likes
  • 2 in conversation