I wonder How SAS Graph template language to decide whether two tick values in the x axis would collide with each other. I know when that happen, sas will choose the Thin Policy(by default) to avoid the collision and there are many other policy to choose by specifying the TICKVALUEFITPOLICY. What I want to know is, how sas "knows" if no TICKVALUEFITPOLICY is specified, there would be ticks overlap on the x axis. If I change the foot size of the tick value, the result is different. Dose that means the space matters?
I have got the reply from SAS Support team and they said:
"Regarding quantitative thresholds, as they correspond to SAS's internal processing, I understand them to be non-public information.
I believe it's best for you to discover what you want to achieve through your own trial and error."
SO, I have began to find an suitable threshold on my own program data hhh. Hope it works.
Really thanks to ballardw (Super User)'s answer, it's helpful~
Going back at least as far as SAS 6.08, 1993 or so, the amount of space, whether on a graph sent direct to printers or files, that the graph occupies has impacted the rules for showing tick marks and default spacing between them when the user did not specify.
The graphing procedures "know" the allowed space for a graph and the number of tick marks required, or requested, for a given axis and option the collision determination is pretty simple math once those pieces of information are determined. Example, if you create an axis of 10 inches length and request 10 ticks it is easy to get 1 inch of space between then (actually more if placed close to the other axis but lets skip that bit). If you reuest 1000 ticks then about 100 need to fit into each inch. The width of the tick itself and most likely any label text then doesn't display well so something needs to be done.
Yes I have created axis with so much overlap that the ticks were useless and illegible at times.
The defaults generally do a good job of getting something usable for the displayed graph.
Hi Ballardw, grateful to receive your reply. I want to give a more detailed PROC Template settings example to explain my question.
Like you say, If I set the length of the width of plot as 16 inch(which means the actual length of the x axis is shorter than 10 inch since the wall area is inside the the whole plot) with :
begingraph /designwidth=16in designheight=9in
and set the size of the tick values as 9pt for example with:
textattrs=(color=black size=9pt);
and I pick a list of tick values I wish to display on the x axis with:
linearopts=(viewmin=0 viewmax=168 tickvaluelist=(0 1 2 4 8 12 24 36 48 72 96 120 144 168)
Then I use proc sgrender to run such proc template.
I will get such a Note:
NOTE: Some of the tick values have been thinned.
Just as I said in my previous blog, I know the SAS would use THIN policy to avoid the tick value collison if there is no enough space for the two tick values to display. What I want to know is, what the exact enought space is. if there is a build-in threshold in SAS such as at least (distance between two tick values)/(total lenght of the x axis)*100% > 2% to allow the two adjacent points show without overlapping.
I wish to design a rule to pick the tick values to show without using the SAS TICKVALUEFITPOLICY like the THIN which means the axis tick values are automatically "thinned" by removing alternating tick values. For this purpose, I need to know how SAS decide whether the tick values are too crowded.
One think you might consider given your example list of tickmarks without any details of the data might be to use a LOG type axis which would change the spacing between the ticks.
SOME value of TICKVALUEFITPOLICY will always be in effect. If you don't specify then you get the default behavior will is going to do what you describe. Maybe using a TICKVALUEFITPOLICY of Rotate or RotateAlways coupled with TICKVALUEROTATION=Vertical , which is going to minimize the width of values displayed on the X axis would reduce the amount of work to select specific values that don't get thinned.
In general the larger the value required to display the less space between integer values.
One way to prevent thinning is to use the range of values in your data, or the plotted subset of the data and do the calculations yourself before setting the value list.
I will give you a simplified version of something I had to do back in the days of SAS 6.08 and early SAS/Graph.
I had data that was read from telemetry daily. Some of the data represented the height of the water column in a rain gauge. The data read was actually a cumulative file, i.e. on one day the file held roughly 24 hours of data, the next day about 48, next 72 and so on until about a weeks worth of data was collected then the loggers were reset. The nature of the rain gauges meant there could be noticeable changes either increases, from precipitation or bugs and birds getting into the buckets, or decreases, when serviced. So the daily graphs that I prepared had to be prepared to deal with as little as 0 change for the 7 day period or as much as spike increases of 15 inches when birds got into the buckets.
I wrote code that examined the range of values for the period and if the value was large enough wrote code to subset the graphs with specified 2 inch ranges of the y axis, each with it's own value list. The 2 inch range per graph was to make sure that we could see the behavior of the column when drastic things weren't happening. If we allowed the whole range to appear as the default then the spikes would make the more typical readings appear flat. I'm sure you have encountered something similar with some data.
Also, you want to determine if the Tick marks are clashing or the Tick Labels. Quite often it is the Label that has an issue and use the options to rotate the text, reduce the size of the text and stagger the text appearance will reduce the conflicts for numbers in the range you show. If using time or date values, a common cause of text long enough to collide then use of a different Format might be in order .
There are enough interactions between the ODS Style, your overrides of style such as text size or font, type of graph template layout (overlay lattice datalattice overlayequated), axis type (discrete log linear time) that just dropping bits of your template can be quite insufficient to tell what will happen.
Look at your LABELFITPOLICY and LABEL POSITION option defaults or settings
I have got the reply from SAS Support team and they said:
"Regarding quantitative thresholds, as they correspond to SAS's internal processing, I understand them to be non-public information.
I believe it's best for you to discover what you want to achieve through your own trial and error."
SO, I have began to find an suitable threshold on my own program data hhh. Hope it works.
Really thanks to ballardw (Super User)'s answer, it's helpful~
Dive into keynotes, announcements and breakthroughs on demand.
Explore Now →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.
Ready to level-up your skills? Choose your own adventure.