TEMPLATE Procedure: Creating a Style Template

Example 4: Defining a Table and Graph Style

Features:
DEFINE STYLE statement style attributes: :
User-defined attributes
Style attribute: BACKGROUNDCOLOR=
Style attribute: BORDERCOLORDARK=
Style attribute: BORDERCOLORLIGHT=
Style attribute: BORDERWIDTH=
Style attribute: CELLPADDING=
Style attribute: BORDERSPACING=
Style attribute: DROPSHADOW=
Style attribute: ENDCOLOR=
Style attribute: FONT=
Style attribute: COLOR=
Style attribute: FRAME=
Style attribute: GRADIENTDIRECTION=
Style attribute: IMAGE=
Style attribute: TEXTALIGN=
Style attribute: style attribute:WIDTH=
Style attribute: RULES=
Style attribute: TRANSPARENCY=
Style attribute: VERTICALALIGN=
DEFINE STYLE statement style elements: :
Style element: GraphAxisLines
Style element: GraphBackground
Style element: GraphBorderLines
Style element: GraphCharts
Style element: GraphLabelText
Style element: GraphWalls

PARENT= statement

STYLE statement

Details

When you are working with styles, you are more likely to modify a SAS style than to write a completely new style. This example shows you how the SAS defined graph style, Science, was created.
Note: Remember that when a STYLE statement creates a style element in the new style, only style elements that explicitly inherit from that style element in the new style inherit the change. When a STYLE statement creates a style element in the new style, all style elements that inherit from that element inherit the definition that is in the new style, so the change appears in all children of the element.

Program

proc template;
     define style Styles.Science;
      parent = styles.default;
      style fonts /
         "TitleFont2" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
         "TitleFont" = ("Verdana, Verdana, Helvetica, sans-serif",18pt,Bold)
         "StrongFont" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
         "EmphasisFont" = ("Verdana, Verdana, Helvetica, sans-serif",10pt,
         Italic)
         "FixedEmphasisFont" = (""Courier New", Courier, monospace",10pt,
         Italic)
         "FixedStrongFont" = (""Courier New", Courier, monospace",10pt,Bold)
         "FixedHeadingFont" = (""Courier New", Courier, monospace",10pt)
         "BatchFixedFont" = (""Courier New", Courier, monospace",10pt)
         "FixedFont" = (""Courier New", Courier, monospace",10pt)
         "headingEmphasisFont" = ("Verdana, Verdana, Helvetica, sans-serif",14
         pt,Bold Italic)
         "headingFont" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)

         "docFont" = ("Verdana, Verdana, Helvetica, sans-serif",8pt,Bold);
style GraphFonts from _self_/
         "GraphValueFont" = ("Verdana",10pt)
         "GraphLabelFont" = ("Verdana",14pt,Bold);
     style colors /
         "headerfgemph" = cx31035E
         "headerbgemph" = cxFFFFFF
         "headerfgstrong" = cx31035E
         "headerbgstrong" = cxFFFFFF
         "headerfg" = cx31035E
         "headerbg" = cxFFFFFF
         "datafgemph" = cx31035E
         "databgemph" = cxDFECE1
         "datafgstrong" = cx31035E
         "databgstrong" = cxDFECE1
         "datafg" = cx31035E
         "databg" = cxDFECE1
         "batchfg" = cx31035E
         "batchbg" = cxDFECE1
         "tablebg" = cx31035E
         "tableborderdark" = cx909090
         "tableborderlight" = cxFFFFFF
         "tableborder" = cxFFFFFF
         "notefg" = cx31035E
         "notebg" = cxDFECE1
         "bylinefg" = cx31035E
         "bylinebg" = cxDFECE1
         "captionfg" = cx31035E
         "captionbg" = cxDFECE1
         "proctitlefg" = cx31035E
         "proctitlebg" = cxDFECE1
         "titlefg" = cx31035E
         "titlebg" = cxDFECE1
         "systitlefg" = cx31035E
         "systitlebg" = cxDFECE1
         "Conentryfg" = cx31035E
         "Confolderfg" = cx31035E
         "Contitlefg" = cx31035E
         "link2" = cx800080
         "link1" = cx0000FF
         "contentfg" = cx31035E
         "contentbg" = cxDFECE1
         "docfg" = cx31035E
         "docbg" = cxDFECE1;
style GraphColors /
         "gconramp3cend" = cxDD6060
         "gconramp3cneutral" = cxFFFFFF
         "gconramp3cstart" = cx6497EB
         "gramp3cend" = cxBED8D3
         "gramp3cneutral" = cxFFFFFF
         "gramp3cstart" = cxAAB6DF
         "gconramp2cend" = cx6497EB
         "gconramp2cstart" = cxFFFFFF
         "gramp2cend" = cx548287
         "gramp2cstart" = cxFFFFFF
         "gtext" = CX31035E
         "glabel" = CX31035E
         "gborderlines" = CX31035E
         "goutlines" = CX31035E
         "ggrid" = CX31035E
         "gaxis" = CX31035E
         "gshadow" = CX707671
         "glegend" = CXFFFFFF
         "gfloor" = CXDFECE1
         "gwalls" = CXFFFFFF
         "gcdata12" = cxFF667F
         "gcdata11" = cx5050CC
         "gcdata10" = cxE100BF
         "gcdata9" = cx007F00
         "gcdata8" = cxB99600
         "gcdata7" = cx7F7F7F
         "gcdata6" = cx984EA3
         "gcdata5" = cx4DAF4A
         "gcdata4" = cxA65628
         "gcdata3" = cxFF7F00
         "gcdata2" = cx377DB8
         "gcdata1" = cxE31A1C
         "gdata12" = CX4A5573
         "gdata11" = CXCFB1E2
         "gdata10" = CX8E829D
         "gdata9" = CX2952B1
         "gdata8" = CXAAB6DF
         "gdata7" = CX6771C2
         "gdata6" = CXBED8D3
         "gdata5" = CX8B65A3
         "gdata4" = CXBCD3AB
         "gdata3" = CX548287
         "gdata2" = CX7DC1C9
         "gdata1" = CX9580D5; 
     style Table from Output /
         cellpadding = 5
         borderspacing = 2
         bordercolordark = colors("tableborderdark")
         bordercolorlight = colors("tableborderlight")
         borderwidth = 2;
     style GraphLabelText from GraphLabelText
         "Label attributes" /
         dropshadow = on;  
      style GraphBackground
         "Graph backgroundcolor attributes" /
         backgroundcolor = colors("docbg")
         image = "!sasroot\common\textures\Science.gif"
         textalign = L
         verticalalign = B;
     style GraphAxisLines from GraphAxisLines
         "Axis line attributes" /
         width = 2;
     style GraphBorderLines from GraphBorderLines
         "Border attributes" /
         width = 2
         color=colors("gaxis");
     style GraphCharts from GraphCharts
         "Chart Attributes" /
         transparency = 0.25;
     style GraphWalls from GraphWalls
         "Wall Attributes" /
         gradientdirection = "Xaxis"
         endcolor = colors("gwalls")
         transparency = 1.0;
   end;
run;

Program Description

Create the style Science. The PROC TEMPLATE statement starts the TEMPLATE procedure. The DEFINE STYLE statement creates a new style in the Styles catalog called Science.
proc template;
     define style Styles.Science;
Specify the parent style from which the Science style inherits its attributes. The PARENT= attribute specifies Styles.Default as the style that the current style inherits from. All the style elements that are specified in the parent's style are used in the current style unless the current style overrides them.
      parent = styles.default;
Change the style attributes of the Fonts style element in the parent style by replacing Fonts in the child style Science. The STYLE statement adds to the child style the style element Fonts, which also exists in the parent style. All style elements that use the user-defined attributes that Fonts defines use the attributes that are specified in the STYLE statement, not the ones that are specified in the Styles.Default style. Because no FROM option is specified, the instance of Fonts in the Science style completely replaces the instance from the Styles.Default style. No style element inheritance occurs.
      style fonts /
         "TitleFont2" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
         "TitleFont" = ("Verdana, Verdana, Helvetica, sans-serif",18pt,Bold)
         "StrongFont" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)
         "EmphasisFont" = ("Verdana, Verdana, Helvetica, sans-serif",10pt,
         Italic)
         "FixedEmphasisFont" = (""Courier New", Courier, monospace",10pt,
         Italic)
         "FixedStrongFont" = (""Courier New", Courier, monospace",10pt,Bold)
         "FixedHeadingFont" = (""Courier New", Courier, monospace",10pt)
         "BatchFixedFont" = (""Courier New", Courier, monospace",10pt)
         "FixedFont" = (""Courier New", Courier, monospace",10pt)
         "headingEmphasisFont" = ("Verdana, Verdana, Helvetica, sans-serif",14
         pt,Bold Italic)
         "headingFont" = ("Verdana, Verdana, Helvetica, sans-serif",14pt,Bold)

         "docFont" = ("Verdana, Verdana, Helvetica, sans-serif",8pt,Bold);
Change the attributes for graph style specific fonts. The STYLE statement adds to the child styles the style element GraphFonts, which also exists in the parent style. All the style elements that use the user-defined attributes that GraphFonts defines use the attributes specified in the STYLE statement, not those specified in the Styles.Default style. Because the FROM option is specified, GraphFonts in the Science style will inherit all of the style attributes from GraphFonts in Styles.Default, except those that are specifically specified in Science.
Instead of the one that is used in this program, you could have used the following STYLE statement : style graphfaonts from graphfonts;
style GraphFonts from _self_/
         "GraphValueFont" = ("Verdana",10pt)
         "GraphLabelFont" = ("Verdana",14pt,Bold);
Change the style attributes of the Colors style element in the parent style by replacing Colors in the style Science. The STYLE statement adds to the child styles the style element Colors, which also exists in the parent style. All style elements that use the user-defined attributes that Colors defines use the attributes that are specified in the STYLE statement, not the ones that are specified in the Styles.Default style. Because no FROM option is specified, the instance of Colors in the Science style completely replaces the instance from the Styles.Default style. No style element inheritance occurs.
     style colors /
         "headerfgemph" = cx31035E
         "headerbgemph" = cxFFFFFF
         "headerfgstrong" = cx31035E
         "headerbgstrong" = cxFFFFFF
         "headerfg" = cx31035E
         "headerbg" = cxFFFFFF
         "datafgemph" = cx31035E
         "databgemph" = cxDFECE1
         "datafgstrong" = cx31035E
         "databgstrong" = cxDFECE1
         "datafg" = cx31035E
         "databg" = cxDFECE1
         "batchfg" = cx31035E
         "batchbg" = cxDFECE1
         "tablebg" = cx31035E
         "tableborderdark" = cx909090
         "tableborderlight" = cxFFFFFF
         "tableborder" = cxFFFFFF
         "notefg" = cx31035E
         "notebg" = cxDFECE1
         "bylinefg" = cx31035E
         "bylinebg" = cxDFECE1
         "captionfg" = cx31035E
         "captionbg" = cxDFECE1
         "proctitlefg" = cx31035E
         "proctitlebg" = cxDFECE1
         "titlefg" = cx31035E
         "titlebg" = cxDFECE1
         "systitlefg" = cx31035E
         "systitlebg" = cxDFECE1
         "Conentryfg" = cx31035E
         "Confolderfg" = cx31035E
         "Contitlefg" = cx31035E
         "link2" = cx800080
         "link1" = cx0000FF
         "contentfg" = cx31035E
         "contentbg" = cxDFECE1
         "docfg" = cx31035E
         "docbg" = cxDFECE1;
Change the style attributes for the GraphColors style element. The STYLE statement adds to the child styles the style element GraphColors, which also exists in the parent style. All of the style elements that use the user-defined attributes that GraphColors define use the attributes that are specified in the Science style, not the attributes that are specified in the Styles.Default style. Because no FROM option is specified, the instance of GraphColors in the Science style completely replaces the instance from the Styles.Default style. No style element inheritance occurs.
style GraphColors /
         "gconramp3cend" = cxDD6060
         "gconramp3cneutral" = cxFFFFFF
         "gconramp3cstart" = cx6497EB
         "gramp3cend" = cxBED8D3
         "gramp3cneutral" = cxFFFFFF
         "gramp3cstart" = cxAAB6DF
         "gconramp2cend" = cx6497EB
         "gconramp2cstart" = cxFFFFFF
         "gramp2cend" = cx548287
         "gramp2cstart" = cxFFFFFF
         "gtext" = CX31035E
         "glabel" = CX31035E
         "gborderlines" = CX31035E
         "goutlines" = CX31035E
         "ggrid" = CX31035E
         "gaxis" = CX31035E
         "gshadow" = CX707671
         "glegend" = CXFFFFFF
         "gfloor" = CXDFECE1
         "gwalls" = CXFFFFFF
         "gcdata12" = cxFF667F
         "gcdata11" = cx5050CC
         "gcdata10" = cxE100BF
         "gcdata9" = cx007F00
         "gcdata8" = cxB99600
         "gcdata7" = cx7F7F7F
         "gcdata6" = cx984EA3
         "gcdata5" = cx4DAF4A
         "gcdata4" = cxA65628
         "gcdata3" = cxFF7F00
         "gcdata2" = cx377DB8
         "gcdata1" = cxE31A1C
         "gdata12" = CX4A5573
         "gdata11" = CXCFB1E2
         "gdata10" = CX8E829D
         "gdata9" = CX2952B1
         "gdata8" = CXAAB6DF
         "gdata7" = CX6771C2
         "gdata6" = CXBED8D3
         "gdata5" = CX8B65A3
         "gdata4" = CXBCD3AB
         "gdata3" = CX548287
         "gdata2" = CX7DC1C9
         "gdata1" = CX9580D5; 
Specify attributes for the table. This STYLE statement is applied to tables. Although these specific attributes are set with this STYLE statement, all other table attributes are inherited from the style elements that are defined in the parent styles.
     style Table from Output /
         cellpadding = 5
         borderspacing = 2
         bordercolordark = colors("tableborderdark")
         bordercolorlight = colors("tableborderlight")
         borderwidth = 2;
Specify attributes for the GraphLabelText element. This STYLE statement is applied to the graph's label text. A DROPSHADOW attribute is applied.
     style GraphLabelText from GraphLabelText
         "Label attributes" /
         dropshadow = on;  
Replace the background for the Graph. This STYLE statement is applied to the graph's background. DOCBG is specified as the background colors, with SCIENCE.GIF justified to the left and bottom as the background image.
      style GraphBackground
         "Graph backgroundcolor attributes" /
         backgroundcolor = colors("docbg")
         image = "!sasroot\common\textures\Science.gif"
         textalign = L
         verticalalign = B;
Specify attributes for the GraphAxisLines element. This STYLE statement is applied to the graph's axis line. The WIDTH is 2.
     style GraphAxisLines from GraphAxisLines
         "Axis line attributes" /
         width = 2;
Specify attributes for the GraphBorderLines element. This STYLE statement is applied to the border lines in the graph. The width is 2 and the foreground color defined in Gaxis, which is CX31035E, is used.
     style GraphBorderLines from GraphBorderLines
         "Border attributes" /
         width = 2
         color=colors("gaxis");
Specify attributes for the GraphCharts element. This STYLE statement is applied to the graph's chart. The data elements of the graph have a TRANSPARENCY of 25%.
     style GraphCharts from GraphCharts
         "Chart Attributes" /
         transparency = 0.25;
Specify attributes for the GraphWalls element. This STYLE statement is applied to the walls inside of the graph's axes. The GRADIENTDIRECTION is set to Xaxis, meaning that the gradient is going left to right. The ENDCOLOR (CXFFFFFF) is defined in Gwalls and is the final color used with the gradient. The data elements of the graph have a TRANSPARENCY of 100%. Because a STARTCOLOR is not specified, the beginning of the gradient is completely transparent.
     style GraphWalls from GraphWalls
         "Wall Attributes" /
         gradientdirection = "Xaxis"
         endcolor = colors("gwalls")
         transparency = 1.0;
Add the style to the specified catalog. The END statement ends the style. The RUN statement executes the PROC TEMPLATE step.
   end;
run;