TEMPLATE Procedure: Creating Table Templates

DEFINE HEADER Statement

Creates a template for a table header or a header inside a column template.
Restriction: The DEFINE HEADER statement can be used only within a column template or a table template.
Requirement: An END statement must be the last statement in the template.
See: Creating a New Table Template

Syntax

DEFINE HEADER header-path | Base.Template.Header
DYNAMIC variable-1 <=default-variable-1>
<'text-1'>
<... variable-n <=default-variable-n><'text-n'>>;
MVAR variable-1 <=default-variable-1><'text-1'>
<... variable-n <=default-variable-n><'text-n'>>;
NMVAR variable-1 <=default-variable-1><'text-1'>
<... variable-n <=default-variable-n><'text-n'>>;
NOTES "text";
TEXT header-specification;
TEXT2 header-specification;
TEXT3 header-specification;
END;

Required Arguments

header-path
specifies where to store the header template. A header-path consists of one or more names, separated by periods. Each name represents a directory in a template store. (A template store is a type of SAS file.) PROC TEMPLATE writes the template to the first writable template store in the current path.
Restrictions:If the template is nested inside of another template, header-path must be a single-level name.

To reference the template that you are creating from another template, do not nest the template inside another template. For example, to reference a header template from multiple columns, do not define the header inside a column template.

Base.Template.Header | Base.Template.Footer
creates a master header template that is globally applied to all of your tabular output. After this template is created, you do not need to explicitly specify it in your SAS programs. It is automatically applied to all tabular output until you specifically remove it from the item store.
Interaction:The Base.Template.Header or Base.Template.Footer master template attributes are overridden by other table templates.

Optional Argument

STORE=libref.template-store
specifies the template store in which to store the template. If the template store does not exist, it is created.
Restrictions:If the template is nested inside another template, do not use the STORE= option for the nested template because it is stored where the original template is stored.

The STORE= option does not become part of the template.

Header Attributes

This section lists all the attributes that you can use in a header template. A column header spans a single column. A spanning header spans multiple columns. These two types of headers are defined in the same way except that a spanning header uses the START= or the END= attribute, or both. For all attributes that support a value of ON, these forms are equivalent:
ATTRIBUTE-NAME
ATTRIBUTE-NAME=ON
For all of the attributes that support a value of variable, variable is any variable that you declare in the table template with the DYNAMIC, MVAR, or NMVAR statement. If the attribute is a Boolean, then the value of variable should resolve to either true or false as shown in this table:
Boolean Values
True
False
ON
OFF
_ON_
_OFF_
TRUE
FALSE
YES
NO
_YES_
_NO_
Header Attributes
Task
Attribute
Destinations
Influence the appearance of the contents of the header
Specify that special characters in headers for generic columns are to be used as split characters
All
Specify whether to try to expand the column width to accommodate the longest word in the column header
LISTING
Specify the horizontal justification for the column header
All except OUTPUT
Specify whether to try to divide the text equally among all lines or to maximize the amount of text in each line when the text in the header uses more than one line
LISTING
Specify whether to draw a continuous line above the header
LISTING
Specify whether to treat the text as preformatted text
Markup family, printer family, and RTF
Specify whether to print the header
All
Specify the number of blank lines to place between the current header and the next header or between the current footer and the previous footer
LISTING
Specify the split character for the header
All except OUTPUT
Specify the style element and any changes to its attributes to use for the header
Markup family, printer family, and RTF
Specify whether to start a new header line in the middle of a word
LISTING
Specify whether to draw a continuous line underneath the header
LISTING
Specify vertical justification for the header
Markup family, PRINTER, family, and RTF
Specify the width of the header in characters
LISTING
Influence the content of the header
Specify a character to use to expand the header to fill the space over the column or columns that the header spans
LISTING
Specify whether to repeat the text of the header until the space that is allotted for the header is filled
LISTING
Influence the placement of the header
Specify the last column that a spanning header covers
All except OUTPUT
Specify the first column that a spanning header covers
All except OUTPUT
Specify whether to expand the header to reach the sides of the page
LISTING
Specify whether a spanning header appears only on the first data panel if the table is too wide to fit in the space that is provided
LISTING, printer family, and RTF
Specify whether a table footer appears only on the last data panel if the table is too wide to fit in the space that is provided
LISTING, printer family, and RTF
Specify whether to extend the text of the header into the header space of adjacent columns
LISTING
Specify whether to extend the text of the header into the adjacent margin
LISTING
Other header attributes
Specify an abbreviation for the header 1
MARKUP
Specify an acronym for the header1
MARKUP
Specify an alternate description for the header1
MARKUP
Specify whether multiple columns can use the header
All except OUTPUT
Specify a long description for the header1
MARKUP
Specify the header template that the current template inherits from
All
1SAS includes these accessibility and compatibility features that improve the usability of SAS for users with disabilities. These features are related to accessibility standards for electronic information technology adopted by the U.S. Government under Section 508 of the U.S. Rehabilitation Act of 1973, as amended.
ABBR= "text" | variable;
specifies an abbreviation for the header. SAS includes this accessibility and compatibility feature that improves the usability of SAS for users with disabilities. This feature is related to accessibility standards for electronic information technology adopted by the U.S. Government under Section 508 of the U.S. Rehabilitation Act of 1973, as amended.
Requirement:The text must be enclosed with quotation marks.
Tip:The ABBR attribute is valid only in the MARKUP destination.
ACRONYM= "text" | variable;
specifies an acronym for the header. SAS includes this accessibility and compatibility feature that improves the usability of SAS for users with disabilities. This feature is related to accessibility standards for electronic information technology adopted by the U.S. Government under Section 508 of the U.S. Rehabilitation Act of 1973, as amended.
Requirement:The text must be enclosed with quotation marks.
Tip:The ACRONYM= attribute is valid only in the MARKUP destination.
ALT= "text" | variable;
specifies an alternate description of the header. SAS includes this accessibility and compatibility feature that improves the usability of SAS for users with disabilities. This feature is related to accessibility standards for electronic information technology adopted by the U.S. Government under Section 508 of the U.S. Rehabilitation Act of 1973, as amended.
Requirement:The text must be enclosed with quotation marks.
Tip:The ALT= attribute is valid only in the MARKUP destination.
DEF_SPLIT;
specifies that special characters in headers for generic columns are to be used as split characters.
Tip:The DEF_SPLIT attribute is valid in all destinations.
END=column-name | variable;
specifies the last column that a spanning header covers.
Default:The last column
Tip:The END= attribute is valid in all destinations except the OUTPUT destination.
EXPAND="string" | variable;
specifies a character to use to expand the header to fill the space over the column or columns that the header spans.
Default:None
Interaction:If you specify both the REPEAT=ON and EXPAND=ON attributes, then the EXPAND= attribute is used.
Tips:If the string or the variable that you specify contains more than one character, then only the first character is used.

The EXPAND= attribute is valid only in the LISTING destination.

EXPAND_PAGE=

EXPAND_PAGE<= ON | OFF | variable>;
specifies whether to expand the header to reach the sides of the page.
Default:OFF
Tip:The EXPAND_PAGE attribute is valid only in the LISTING destination.
See:EXPAND=
FIRST_PANEL<= ON | OFF | variable>;
specifies whether a spanning header appears only on the first data panel if the table is too wide to fit in the space that is provided.
Default:OFF
Restriction:Applies only to headers, not to footers
Tip:The FIRST_PANEL attribute is valid in the LISTING, printer family, and RTF destinations.
FORCE<= ON | OFF | variable>;
specifies whether to try to expand the column width to accommodate the longest word in the column header. The column width can be anything between the values for the WIDTH= and WIDTH_MAX= column attributes.
Default:ON
Tip:The FORCE= attribute is valid only in the LISTING destination.
GENERIC<= ON | OFF | variable> ;
specifies whether multiple columns can use the header.
Default:OFF
Restriction:This attribute is primarily for writers of SAS procedures and for DATA step programmers.
Tip:The GENERIC= attribute is valid in all destinations except the OUTPUT destination.
JUST=justification | variable;
specifies the horizontal justification for the column header, where justification is one of the following:
LEFT
specifies left justification.
Alias:L
RIGHT
specifies right justification.
Alias:R
CENTER
specifies center justification.
Alias:C
Default:The justification for the column
Tip:The JUST= attribute is valid in all destinations except the OUTPUT destination.
LAST_PANEL<= ON | OFF | variable> ;
specifies whether a table footer appears only on the last data panel if the table is too wide to fit in the space that is provided.
Default:OFF
Restriction:Applies only to footers, not to headers
Tip:The LAST_PANEL= attribute is valid only in the LISTING, printer family, and RTF destinations.
LONGDESC= "string" | variable;
specifies the long description of the header. SAS includes this accessibility and compatibility feature that improves the usability of SAS for users with disabilities. This feature is related to accessibility standards for electronic information technology adopted by the U.S. Government under Section 508 of the U.S. Rehabilitation Act of 1973, as amended.
Requirement:The text must be enclosed within quotation marks.
Tip:The LONGDESC= attribute is valid only in markup family destinations.
MAXIMIZE<=ON | OFF | variable> ;
specifies whether to try to divide the text equally among all lines or to maximize the amount of text in each line when the text in the header uses more than one line. For example, if the text spans three lines, MAXIMIZE=ON can result in 45% of the text on the first line, 45% of the text on the second line, and 10% of the text on the third line. MAXIMIZE=OFF can result in 33% of the text on each line. MAXIMIZE=ON can write lines of text that vary greatly in length. MAXIMIZE=OFF can result in using less than the full column width.
Default:OFF
Tip:The MAXIMIZE= attribute is valid only in the LISTING destination.
OVERLINE<=ON | OFF | variable>;
specifies whether to draw a continuous line above the header. The second formatting character is used to draw the line. See the discussion of FORMCHAR= "string" | variable;.
Default:OFF
Tip:The OVERLINE= attribute is valid only in the LISTING destination.
PARENT=header-path;
specifies the header template that the current template inherits from. A header-path consists of one or more names, separated by periods. Each name represents a directory in a template store. (A template store is a type of SAS file.) The current template inherits from the specified header template in the first readable template store in the current path.
When you specify a parent, all of the attributes and statements that are specified in the parent's template are used in the current template unless the current template specifically overrides them.
Tip:The PARENT= attribute is valid in all destinations.
PREFORMATTED<=ON | OFF | variable>;
specifies whether to treat the text as preformatted text. When text is preformatted, ODS honors line breaks as well as leading, trailing, and internal spaces. It also displays the text in a monospace font.
Default:OFF
Interactions:When PREFORMATTED=ON, and you are defining a table header or a footer, ODS uses the HeaderFixed or the FooterFixed style element unless you specify another style element with the STYLE= column attribute.

When PREFORMATTED=ON, and you are defining a column header, ODS uses the RowHeaderFixed style element unless you specify another style element with the STYLE= column attribute.

Tip:The PREFORMATTED attribute is valid in the markup family, printer family, and RTF destinations.
PRINT<=ON | OFF | variable>;
specifies whether to print the header.
Default:ON
Tips:When PRINT=ON, the column header becomes the label of the corresponding variable in any output data sets that the OUTPUT destination creates if neither the column template nor the data component provides a label.

The PRINT= attribute is valid in all destinations.

REPEAT<=ON | OFF | variable>;
specifies whether to repeat the text of the header until the space that is allotted for the header is filled.
Default:OFF
Interaction:If you specify both the REPEAT=ON and EXPAND=ON attributes, then the EXPAND= attribute is used.
Tip:The REPEAT attribute is valid only in the LISTING destination.
SPACE=positive-integer | variable;
specifies the number of blank lines to place between the current header and the next header or between the current footer and the previous footer.
Default:0
Tips:A row of underlining or overlining is considered a header or a footer.

The SPACE= attribute is valid only in the LISTING destination.

SPILL_ADJ<=ON | OFF | variable>;
specifies whether to extend the text of the header into the header space of adjacent columns.
Default:OFF
Interaction:FORCE=, SPILL_MARGIN=, SPILL_ADJ=, and TRUNCATE= are mutually exclusive. If you specify more than one of these attributes, then only one of these attributes are used. FORCE= takes precedence over the other three attributes, followed by SPILL_MARGIN=, SPILL_ADJ=, and TRUNCATE=.
Tip:The SPILL_ADJ attribute is valid only in the LISTING destination.
SPILL_MARGIN<=ON | OFF | variable>;
specifies whether to extend the text of the header into the adjacent margin.
Default:ON
Restriction:SPILL_MARGIN= applies only to a spanning header that spans all the columns in a data panel.
Interaction:The FORCE=, SPILL_MARGIN=, SPILL_ADJ=, and TRUNCATE= attributes are mutually exclusive. If you specify more than one of these attributes, then only one of these attributes are used. The FORCE= attribute takes precedence over the other three attributes, followed by SPILL_MARGIN=, SPILL_ADJ=, and TRUNCATE=.
Tip:The SPILL_MARGIN attribute is valid only in the LISTING destination.
SPLIT= "character" | variable;
specifies the split character for the header. PROC TEMPLATE starts a new line when it reaches that character and continues the header on the next line. The split character itself is not part of the header although each occurrence of the split character counts toward the maximum length for a label.
The first character in a header defines the split character if it is not one of the following:
  • an alphanumeric character
  • a blank
  • an underscore (_)
  • a hyphen (-)
Note: The split will not occur until the split character appears after text.
Tip:The SPLIT= attribute is valid in all destinations except the OUTPUT destination.
START=column-name | variable;
specifies the first column that a spanning header covers.
Default:The first column
Tip:The START= attribute is valid in all destinations except the OUTPUT destination.
STYLE=<style-element-name><[style-attribute-specification(s)]>;
specifies the style element and any changes to its attributes to use for the header.
style-element-name
is the name of the style element to use to produce the header. The style element must be part of a style that is registered with the Output Delivery System. SAS provides some styles. You can create customized styles by using PROC TEMPLATE (see DEFINE STYLE Statement).
By default, ODS produces different parts of ODS output with different elements. For example, by default, a table header is displayed with the style element Header. The style elements that you would be most likely to use with the STYLE= attribute for a table header are as follows:
  • Header
  • HeaderFixed
  • HeaderEmpty
  • HeaderEmphasis
  • HeaderEmphasisFixed
  • HeaderStrong
  • HeaderStrongFixed
The style elements that you would be most likely to use with the STYLE= attribute for a table footer are as follows:
  • Footer
  • FooterFixed
  • FooterEmpty
  • FooterEmphasis
  • FooterEmphasisFixed
  • FooterStrong
  • FooterStrongFixed
The style elements that you would be most likely to use with the STYLE= attribute for a column header are as follows:
  • Rowheader
  • RowheaderFixed
  • RowheaderEmpty
  • RowheaderEmphasis
  • RowheaderEmphasisFixed
  • RowheaderStrong
  • RowheaderStrongFixed
The style element provides the basis for displaying the header. Additional style attributes that you provide can modify the display.
style-element-name is either the name of a style element or a variable whose value is a style element.
style-attribute-specification
describes the style attribute to change. Each style-attribute-specification has this general form:
style-attribute-name=style-attribute-value
Requirement:The STYLE= option requires either a style-attribute-specification or a style-element-name.
Tips:You can use braces ({ and }) instead of square brackets ([ and ]).

If you use the STYLE= attribute inside a quoted string, then add a space before or after the carriage return to prevent errors. SAS does not interpret a carriage return as a space. You must explicitly specify spaces in quoted strings.

The STYLE= attribute is valid only in the markup family, printer family, and RTF destinations.

TRUNCATE<=ON | OFF | variable>;
specifies whether to start a new header line in the middle of a word.
ON
starts a new line of the header when the text fills the specified column width.
OFF
extends the width of the column to accommodate the longest word in the column header, if possible. TRUNCATE=OFF is the same as FORCE=ON.
Default:OFF
Interaction:If you specify FORCE=, SPILL_MARGIN=, or SPILL_ADJ=, then the TRUNCATE= attribute is ignored.
Tip:The TRUNCATE= attribute is valid only in the LISTING destination.
UNDERLINE<=ON | OFF | variable> ;
specifies whether to draw a continuous line below the header. The second formatting character is used to draw the line.
Default:OFF
Tip:The UNDERLINE attribute is valid only in the LISTING destination.
See:For information about formatting characters, see the discussion of FORMCHAR= table attribute.
VJUST=justification | variable;
Specifies vertical justification for the header. justification is one of the following:
TOP
places the header as high as possible.
Alias:T
CENTER
centers the header vertically.
Alias:C
BOTTOM
places the header as low as possible.
Alias:B
Default:BOTTOM
Tip:The VJUST= attribute is valid only in the MARKUP and PRINTER families of destinations.
WIDTH=positive-integer | variable;
specifies the width of the header in characters.
Default:If you omit a width, the column width is used.
Tips:To create a vertical header, specify a width of 1.

The WIDTH= attribute is valid only in the LISTING destination.