Understanding Styles, Style Elements, and Style Attributes

Overview

To customize the output at the level of your entire output stream in a SAS session, you specify a style. A style describes how to generate the presentation aspects (color, font face, font size, and so on) of the entire SAS output. A style determines the overall look of the documents that use it.
Each style consists of style elements. A style element is a collection of style attributes that apply to a particular part of the output. For example, a style element might contain instructions for the presentation of column headings, or for the presentation of the data inside the cells. Style elements might also specify default colors and fonts for output that uses the style.
Each style attribute specifies a value for one aspect of the presentation. For example, the BACKGROUND= attribute specifies the color for the background of an HTML table or for a colored table in printed output. The FONTSTYLE= attribute specifies whether to use a Roman or an italic font. For information about style attributes, see the section on style attributes in TEMPLATE Procedure: Creating a Style Template.
Note: Because styles control the presentation of the data, they have no effect on output objects that go to the LISTING or OUTPUT destination.

Using the Template Browser Window

To help you become familiar with styles, style elements, and style attributes, look at the relationship between them. The following program creates a style, Concepts.Style. The diagram that follows the program shows the relationship between the style, the style elements, and the style attributes.
proc template;
   define style concepts.style;
      style celldata /
         fontfamily="roman, arial"
         color=blue
         fontweight =bold
         "dark"=black;
      style cellemphasis from celldata /
         color=celldata("dark")
         borderspacing=10;
   end;
run;
Diagram of a Style, Including Style Elements and Style Attributes
Diagram of a Style, Including Style Elements and Style Attributes
The following list corresponds to the numbered items in the preceding diagram:
Note: For a list of the default style elements used for HTML and markup languages and their inheritance, see ODS Style Elements.
1 Concepts.Style is a style. Styles describe how to display presentation aspects (color, font, font size, and so on) of the output for an entire SAS job. A style determines the overall appearance of the ODS documents that use it. Each style consists of style elements. Styles are created with the DEFINE STYLE Statement. New styles can be created independently or from an existing style. You can use the PARENT= Statement to create a new style from an existing style.
2 CellData and CellEmphasis are style elements. A style element is a collection of style attributes that apply to a particular part of the output for a SAS program. For example, a style element might contain instructions for the presentation of column headings or for the presentation of the data inside table cells. Style elements might also specify default colors and fonts for output that uses the style. Style elements exist inside of styles and are defined by the STYLE Statement.
Note: For a list of the default style elements used for HTML and markup languages and their inheritance, see ODS Style Elements.
3 The following are style attribute-value pairs:
  • fontfamily="roman, arial"
  • color=blue
  • fontweight=bold
  • "dark"=black
  • color=celldata("dark")
  • borderspacing=10
Style attributes specify a value for one aspect of the presentation. For example, the COLOR= attribute specifies the value blue for the foreground color of a table, and the FONTFAMILY= attribute specifies the values roman and arial as the font to use. Style attributes exist within style elements and can be supplied by SAS or be user-defined. FONTFAMILY=, COLOR=, FONTWEIGHT=, and BORDERSPACING= are style attributes supplied by SAS. For a list of style attributes supplied by SAS, see Style Attributes Tables .
4 "Dark" is a user-defined style attribute. It specifies to substitute the value black whenever the value "dark" is specified.
5 The value celldata("dark") is a style reference. Style attributes can be referenced with style references. This style reference specifies that PROC TEMPLATE go to the CellData style element and use the value that is specified for the "dark" style attribute. See style-reference for more information about style references.
You can view the style elements and style attributes in any style from the Template Browser window in the SAS windowing environment. To view the Template Browser:
  1. From any window in an interactive SAS session, select Viewthen selectResults
  2. In the Results window, select Viewthen selectTemplates
  3. In the Templates window, select and open Sashelp.Tmplmst.
  4. Select and open the Styles folder, which contains a list of available styles. If you want to view the underlying SAS code for a style, then select the style and open it.
    Windows Specifics: For information about navigating in the Explorer window without a mouse, see the section on “Window Controls and General Navigation” in the SAS documentation for your operating environment.
Viewing the HTMLBlue Style in the Template Browser
Viewing the HTMLBlue Style in the Template Browser

Styles That Are Shipped with SAS Software

Base SAS software is shipped with many styles. To see a list of these styles, view them in the SAS Explorer Window, use the TEMPLATE procedure, or use the SQL procedure.
  • SAS Explorer Window:
    To display a list of the available styles using the SAS Explorer Window, follow these steps:
    1. From any window in an interactive SAS session, select View then selectResults
    2. In the Results window, select View then selectTemplates
    3. In the Templates window, select and open Sashelp.tmplmst.
    4. Select and open the Styles folder, which contains a list of available styles. If you want to view the underlying SAS code for a style, then select the style and open it.
    Operating Environment Information: For information about navigating in the Explorer window without a mouse, see the section on "Window Controls and General Navigation" in the SAS documentation for your operating environment.
  • TEMPLATE Procedure:
    You can also display a list of the available styles by submitting the following PROC TEMPLATE statements:
    proc template;
       list styles;
    run;
  • SQL Procedure:
    You can also display a list of the available styles by submitting the following PROC SQL statements:
    proc sql;
    select * from dictionary.styles;
    quit;
For more information about how ODS destinations use styles and how you can customize styles, see the DEFINE STYLE Statement.

Using Styles with Base SAS Procedures

  • Most Base SAS Procedures
    Most Base SAS procedures that support ODS use one or more table templates to produce output objects. These table templates include templates for table elements: columns, headers, and footers. Each table element can specify the use of one or more style elements for various parts of the output. These style elements cannot be specified within the syntax of the procedure, but you can use customized styles for the ODS destinations that you use. For more information about customizing tables and styles, see TEMPLATE Procedure: Creating a Style Template.
  • The PRINT, REPORT, and TABULATE Procedures
    The PRINT, REPORT, and TABULATE procedures provide a way for you to access table elements from the procedure step itself. Accessing the table elements enables you to do such things as specify background colors for specific cells, change the font face for column headings, and more. The PRINT, REPORT, and TABULATE procedures provide a way for you to customize the markup language and printed output directly from the procedure statements that create the report. For more information about customizing the styles for these procedures, see the Base SAS Procedures Guide.