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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 460 views
  • 4 likes
  • 2 in conversation