Hi,
Is there a way to specify grid interval without specifying the minimum and max of the axis?
For example, we typically have this for the specs of the axis:
axis1 order=(0 to 100 by 10);
But my range for the axis changes and I don't want to specify it. But I need to specify the interval.
Is there a way to do that?
Thanks.
Jason
When I had a similar need I used to pull the max and min values of the variable, round up or down (floor and ceiling functions) as needed to multiples of the interval and had those values assigned to macro variables. Then the Axis definition would use the min and max macro variable values in the ORDER section of the Axis statement. The problem with this approach is your data may occasionally have a range large enough that for your desired interval the results are illegible or that SAS can't use such as 10 to 10000 by 10.
You might also experiment with using the MAJOR=(Number = n) to use a standard number of tick marks and let the interval fall as it may.
Thanks. I'll try that.
Would it suffice to include a short proc sql to get the min, max and interval into macro variables that could then be used for your axis statement? e.g.:
data have;
input x;
cards;
1
5
9
18
26
30
;
proc sql noprint;
select min(x),max(x),round((max(x)-min(x))/10)
into :min,:max,:interval
from have
;
quit;
axis1 order=(&min. to &max. by &interval.);
Thank you.
You might consider the IML routine GSCALE which will be more powerful(option wise) and produced more pleasing results.
Thank you!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.