SAS Institute. The Power to Know

SAS/GRAPH(R) 9.2 Reference

Previous Page | Next Page

Controlling The Appearance of Your Graphs

Modifying a Style


Using the TEMPLATE Procedure

Within the TEMPLATE procedure, you can use the DEFINE STYLE statement to create your own style from scratch or from an existing style. When you create styles from existing styles, you can modify the individual style elements.

For complete documentation on using PROC TEMPLATE to modify and create styles, see TEMPLATE Procedure: Creating a Style Definition 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 = shortdash 
         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.


Modifying Graph Fonts Or Colors Specified By Styles

There are different ways to modify the fonts or colors used by a style. Which method you choose depends on how extensively you want to change a font or color. You can do any of the following:

  • Modify a style element that controls a specific graphical element. For example, the GraphValueText element specifies the default font and color for tick mark values and legend value descriptions. You could modify the font or color specified by the GraphValueText element for the Analysis style. See Style Elements that Affect SAS/GRAPH Output for information on the specific style elements that you can modify. Changes to specific style elements affect only those elements and affect them only in the styles where you change them.

  • Modify the font specifications in the GraphFonts style element or the color specifications in the GraphColors style element for a specific style. Other style elements that reference the GraphFonts or GraphColors style elements will use the modified settings. See The GraphFonts Style Element and The GraphColors Style Element for more information.

  • 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 default 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. See "Changing SAS Registry Settings for ODS" in SAS Output Delivery System: User's Guide for more information. (Colors used by the styles cannot be 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 default 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.

class GraphFonts 
         "Fonts used in graph styles" /  
         'GraphDataFont' = ("<sans-serif>, <MTsans-serif> ",7pt)  
         'GraphValueFont' = ("<sans-serif>, <MTsans-serif> ",9pt) 
         'GraphLabelFont' = ("<san-serif>, <MTsan-serif> ",10pt,bold) 
         'GraphFootnoteFont' = ("<san-serif>, <MTsan-serif>",10pt) 
         'GraphTitleFont' = ("<san-serif>, <MTsan-serif> ",11pt,bold);

For example, the GraphValueText element uses the font specified by the GraphValueFont attribute in the GraphFonts style element as its default font. GraphValueText uses the color specified by the gtext attribute in the GraphColors style element as its default color.

class GraphValueText / 
         font = GraphFonts('GraphValueFont') 
         color = GraphColors('gtext');

The GraphValueText element specifies the font and color for tick mark values and legend value descriptions (see Style Elements that Affect SAS/GRAPH Output). You can change the font for tick mark values and legend value descriptions by modifying the GraphValueText element directly or by modifying GraphValueFont attribute in the GraphFonts style element. Similarly, you can change the color for tick mark values and legend value descriptions by modifying the GraphValueText element or by modifying the gtext attribute in the GraphColors style element.

If you modify the GraphValueText element, 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 tables listed in Graphical Style Element Reference describe the portions of SAS/GRAPH output that are affected by elements and attributes defined in the styles.

Previous Page | Next Page | Top of Page