09-17-2014 08:45 AM
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.
09-17-2014 09:45 AM
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:
do i = 1 to 100;
x = rand("normal");
y = rand("normal");
proc sgplot data=a;
scatter x=x y=y;
xaxis values=(-5 to 5 by 5);
09-17-2014 09:56 AM
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.
09-26-2014 07:03 AM
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.
09-26-2014 09:42 AM
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 */
if mod(_N_,2) then height=-height;
proc sgplot data=class;
scatter x=height y=weight;
xaxis min=-&maxcount max=&maxcount
values=(-&maxcount 0 &maxcount -50 to 50 by 20);
09-26-2014 10:44 AM
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