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

I want to create a graph with a fixed x-axis range using the SGPLOT command. Specifically, I want the x-axis to range from -100 to 100 by 10. However, when I ran the code, the x-axis displayed a range of -25 to -75 by 25 instead.

 

Here is my code:

 

proc sgplot data=test5aT nowall noborder nocycleattrs dattrmap=attrmap noautolegend ;
title 'A';

format text $txt.;
styleattrs axisextent=data ;
highlow y=obsid low=low high=high/lineattrs=(thickness=.05);
scatter y=obsid x=percent / markerattrs=(symbol=circle size=10);
refline 1 / axis=x noclip;
text x=xl y=obsid text=text / position=bottom contributeoffsets=none strip;
yaxistable exposure / location=inside position=left textgroup=id labelattrs=(size=12 Weight=Bold);
yaxistable nobsused / location=inside position=left labelattrs=(size=12 Weight=Bold) valueattrs=(size=9);
yaxistable iqr percent _95/ location=inside position=left;

yaxis reverse display=none;
xaxis labelattrs=(size=12) valueattrs=(size=9);
x2axis min=-100 max=100 values=(-100 to 100 by 10)display=all labelattrs=(size=9) offsetmin=0 offsetmax=0;
xaxis label='Rate (%)' LABELPOS=DATACENTER labelattrs=(color=Black size=9 WEIGHT= BOLD);
run;

1 ACCEPTED SOLUTION

Accepted Solutions
quickbluefish
Barite | Level 11
You have two xaxis statements - get rid of the semicolon on the first line and get rid of the 'xaxis' on the 2nd line and you should be good.

View solution in original post

4 REPLIES 4
ballardw
Super User

Your values list is for an X2AXIS, or the top of the graph. I don't see any plot actually using the X2AXIS though.

 

Strong hint: ONE Xaxis and ONE Yaxis statement with all the options.

We see cases where multiple statements only have the last Xaxis or Yaxis statement applied.

 

 

Rayhan
Calcite | Level 5

I also use following ways but didn't get fixed x axis


xaxis values=(-100 to 100 by 10) labelattrs=(size=12) valueattrs=(size=9);
xaxis label='Excess rate (%)' LABELPOS=DATACENTER labelattrs=(color=Black size=9 WEIGHT= BOLD);
run;

quickbluefish
Barite | Level 11
You have two xaxis statements - get rid of the semicolon on the first line and get rid of the 'xaxis' on the 2nd line and you should be good.
Rayhan
Calcite | Level 5
Thanks a lot, it works.

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

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 987 views
  • 0 likes
  • 3 in conversation