The section Modifying Tick Marks and Grid Lines explains that grid lines in graphs are controlled both by template options and by the style. Some graphs never display grid
lines because they would interfere with the display. Some graphs always display grid lines because they are a critical part
of the display. In both cases, grid control is so important that the template writer is not willing to give control to the
style. If you want to change the grid display setting for these graphs, you must edit their templates. However, most templates
let the style control the grid lines. Either they do not display grid lines unless the style forces them on, or they display
grid lines unless the style forces them off. The HTMLBLUE, STATISTICAL, DEFAULT, and most other styles use the setting DisplayOpts = "Auto"
. Then templates that specify GRIDDISPLAY=AUTO_OFF (the default) do not display grid lines, and templates that specify GRIDDISPLAY=AUTO_ON
do display grid lines. You can easily make a new style with DisplayOpts = "On"
or DisplayOpts = "Off"
if you would prefer to see grid lines more or less often. This example shows how to set DisplayOpts = "On"
.
First, you need to find the part of the style that enables grid lines. The following step displays the HTMLBLUE style and uses the EXPAND option to display its parent styles, STATISTICAL and DEFAULT:
proc template; source Styles.HTMLBlue / expand; run;
The advantage of displaying all three styles together is that you can do one search of the results. If grids are defined in the HTMLBLUE style, you will find that first. Otherwise, you will first find the definition in one of the parent styles. An abridged version of the results follows:
. . . class GraphGridLines / displayopts = "auto" linethickness = 1px linestyle = 1 contrastcolor = GraphColors('ggrid') color = GraphColors('ggrid'); . . .
You can use this to create a new style that inherits from the HTMLBLUE style, but sets the display options for grids to ON, as in the following example:
proc template; define style Styles.MyGrids; parent=styles.HTMLBlue; class GraphGridLines / displayopts = "on" linethickness = 1px linestyle = 1 contrastcolor = GraphColors('ggrid') color = GraphColors('ggrid'); end; run;
You can use this new style as in the following example:
ods graphics on; ods listing style=mygrids; proc robustreg data=stack plots=qqplot; ods select QQPlot; model y = x1 x2 x3; run;
The preceding statements produce Output 22.1.5, which shows the Q-Q plot with grid lines displayed. The default graph template that SAS supplies is used because the custom template created in the section Modifying Tick Marks and Grid Lines is deleted at the end of that section.
Output 22.1.5: A Style that Makes Grid Lines the Typical Default