Contributor
Posts: 60

# How to get axis values symmetrical SGPLOT

I am losing my mind here. I just can not get the X axis on my SGPLOT to be symmetrical. I define values (-&count to &count by 5) in the xaxis statement and what happens is that SAS just randomly decides which of the values it should show for example the axis could be lik -11 -6 -1 4 9 14 which makes just no sense. I would need to get the axis to always contain 0 and then have symmetrically distributed value ticks around 0 witht the MIN/MAX value being at the end of the values list. How can I do this? Is there some style element that drives this? I have tried to force this by assigning also white reflines at the MIN and MAX points with noclip option but it does not work.

SAS Super FREQ
Posts: 3,843

## Re: How to get axis values symmetrical SGPLOT

It would be helpful if you could post your code so we know what options you tried. Here is a program that works for simulated data. It uses the VALUES= option to set the axis tick locations:

data a;
do i = 1 to 100;
x = rand("normal");
y = rand("normal");
output;
end;
run;

proc sgplot data=a;
scatter x=x y=y;
xaxis values=(-5 to 5 by 5);
run;

SAS Super FREQ
Posts: 1,199

## Re: How to get axis values symmetrical SGPLOT

It is not random, but based on THRESHOLD setting.  These options on the axis decide if the outer tick values are actually shown based on the distance form the actual extreme value to the extreme tick value for the axis.  With SAS 9.3, SGPLOT supports ThresholdMin and ThresholdMax.  There is a ValueList option for you to always get the ticks you want.  Set ValuesHint to indicate that only the values in the list that are actually in the data should be used.

SAS Super FREQ
Posts: 3,843

## Re: How to get axis values symmetrical SGPLOT

To me it sounds like the OP does not want to use the VALUESHINT option.

Contributor
Posts: 60

## Re: How to get axis values symmetrical SGPLOT

Thanks this seems helpful, but could you provide some instructions how to use these options since they are not documented anywhere. I attached a screenshot of the current situation (with %let maxcount=162) and the code concerning the xaxis is the following:

xaxis values=(-&maxcount. to &maxcount) refticks label="Count" integer;

And what I would need is that the both (right and left) end points would be 162 and also that the 0 tick would always appear (now it is missing between 15 and 6). Also symmetry of the values would be a added bonus.

PS. I have modified the values with formats to show negative numbers as positive.

SAS Super FREQ
Posts: 3,843

## Re: How to get axis values symmetrical SGPLOT

I think you want to use MIN= and MAX= to set the axis lengths, then specify your values with the VALUES= option.

The VALUES= list will include +/-&maxcount, 0, and some equally spaced points, like this:

/* generate some negative data */
data class;
set sashelp.class;
if mod(_N_,2) then height=-height;
run;

%let maxcount=80;
proc sgplot data=class;
scatter x=height y=weight;
xaxis min=-&maxcount max=&maxcount
values=(-&maxcount 0 &maxcount  -50 to 50 by 20);
run;

SAS Employee
Posts: 232

## Re: How to get axis values symmetrical SGPLOT

Thanks for the questions and answers. Just so you all know I moved this to the SAS Statical Procedures community so folks there can find the content. It was in the general community before. Thanks, LainieH

Discussion stats
• 6 replies
• 946 views
• 0 likes
• 4 in conversation