Modifying a Style

Using the TEMPLATE Procedure

Within the TEMPLATE procedure, you can use the DEFINE STYLE statement to create a completely new style or you can start from an existing style. When you create styles from existing styles, you can modify the individual style elements.
For complete documentation about using PROC TEMPLATE to modify and create styles, see TEMPLATE Procedure: Creating a Style Template in SAS Output Delivery System: User's Guide in SAS Output Delivery System: User's Guide.

Example: Modifying a Style Element

The style element GraphData1 is defined in the Default style as follows:
proc template;  
   define style Styles.Default; 
        ...more style elements... 
   class GraphData1 /  
           markersymbol = "circle"  
           linestyle = 1 
           contrastcolor = GraphColors('gcdata1') 
           color = GraphColors('gdata1'); 
You can use the DEFINE STYLE statement in the TEMPLATE procedure to create a new style from the Default style and modify the GraphData1 style element. The following program creates the new style MyStyleDefault, which inherits all of its style elements and style attributes from the Default style, and modifies the GraphData1 style element:
proc template; 
   define style MyStyleDefault;
   parent=Styles.Default;   
   style GraphData1 from GraphData1 /   
         markersymbol = "triangle"  
         linestyle = 2 
         contrastcolor = GraphColors("gcdata1") 
         color = GraphColors("gdata1"); 
    end;
run;
The new GraphData1 uses the same colors as the original GraphData1, but specifies a different marker symbol and line style.
To use the new MyStyleDefault style for HTML output, specify the STYLE= option:
ods html style=MyStyleDefault;

Ways to Modify Graph Fonts or Colors Specified by Styles

There are different ways to change the fonts or colors used by a style. Which method you choose depends on how extensively you want to change the font or color specifications used in your output. You can do any of the following:
  • Modify a specific style element that controls a specific graphical element. For example, the GraphValueText element specifies the font and color for tick mark values and legend value descriptions. You could change the font or color specified by the GraphValueText element for the Analysis style. Changes to specific style elements affect only the graphical elements that they control and affect them in only the styles where you change them. See Style Elements for Use with SAS/GRAPH Output for information about the specific style elements that you can modify.
  • Modify the font or color specifications in the GraphFonts or GraphColors style elements for a specific style. The settings specified in GraphFonts and GraphColors are referenced by specific style elements elsewhere in the style. Other style elements that reference the GraphFonts or GraphColors style elements use the modified settings. See The GraphFonts Style Element and The GraphColors Style Element for more information. A single change in the specifications in the GraphFonts or GraphColors style elements can potentially change the appearance of several graphical elements and affect output of any style that refers to GraphFonts or GraphColors.
  • Modify the font settings for one or more subkeys in the SAS registry. Many styles refer to the font settings in the SAS registry to determine the fonts to use for various graphical elements. Modifying the SAS registry settings changes the fonts used for all styles that refer to the subkeys that you change. For more information, see Changing SAS Registry Settings for ODS in SAS Output Delivery System: User's Guide. (Colors used by the styles supplied by the company are not controlled through the SAS registry.)

Modifying the GraphFonts and GraphColors Style Elements

The attributes in the GraphFonts and GraphColors style elements are used as the values for specific style elements elsewhere in the style. In other words, the GraphFonts and GraphColors elements are abstract elements. They are used to assign values to other elements.
For example, the GraphFonts element could be defined follows:
class GraphFonts 
         "Fonts used in graph styles" /  
         'GraphDataFont' = ("<sans-serif>, <MTsans-serif> ",7pt)  
         'GraphValueFont' = ("<sans-serif>, <MTsans-serif>",9pt) 
         'GraphLabelFont' = ("<sans-serif>, <MTsans-serif> ",10pt,bold) 
         'GraphFootnoteFont' = ("<sans-serif>, <MTsans-serif>",10pt) 
         'GraphTitleFont' = ("<sans-serif>, <MTsans-serif>",11pt,bold);
Each attribute, GraphDataFont, GraphValueFont, GraphLabelFont, and so on, defines a list of fonts for use by SAS/GRAPH whenever the corresponding attribute is referenced. These attributes are specified elsewhere in the style as the value of a another font attribute. (For information about the syntax used in the GraphFonts style element, see Font Specifications in the GraphFonts Style Element.)
For example, the GraphValueText element specifies the font and color for tick mark values and legend value descriptions. Suppose the GraphValueText element is defined as follows:
class GraphValueText / 
         font = GraphFonts('GraphValueFont') 
         color = GraphColors('gtext');
The font and color for GraphValueText are specified by elements in the GraphFonts and GraphColors style elements.
GraphFonts('GraphValueFont')
tells SAS/GRAPH to use the font specified by the GraphValueFont attribute in the GraphFonts style element.
GraphColors('gtext')
tells SAS/GRAPH to use the color specified by the gtext attribute in the GraphColors style element.
To change the font and color for tick mark values and legend value descriptions, you could modify either of the following:
  • the FONT= and COLOR= attributes in the GraphValueText element
  • the GraphValueFont attribute in the GraphFonts style element and the gtext attribute in the GraphColors style element.
However, because elements in GraphFonts and GraphColors are referred to by other elements in the style, changing the values in GraphFonts and GraphColors result in more extensive changes than modifying a specific style element such as GraphValueText directly. If you modify the GraphValueText element directly, your modifications affect only the items controlled by GraphValueText. If you modify the GraphValueFont or gtext attributes, then your modifications might affect other portions of the graph in addition to tick mark values and legend value descriptions. This list includes pie labels, regression equations, data point labels, bar labels, and graph titles.
The styles supplied with SAS/GRAPH are designed to provide a consistent visual appearance for all graphical elements in your output. Modifying attributes in the GraphFonts or GraphColors elements instead of modifying several specific style elements makes it easier to maintain the consistent appearance in your output.
The tables listed in Graphical Style Element Reference for Device-Based Graphics describe the portions of SAS/GRAPH output that are affected by elements and attributes defined in the styles.