Previous Page | Next Page

TEMPLATE Procedure: Creating Tabular Output

DEFINE HEADER Statement


Creates a template for a table header.
Requirement: An END statement must be the last statement in the template.
Featured in: Creating a New Table Template

DEFINE HEADER header-path | Base.Template.Header
</ STORE=libref.template-store>;
<header-attribute-1; <... header-attribute-n; >>
DYNAMIC variable-1 <"text-1"> <... variable-n <"text-n">>;
MVAR variable-1 <"text-1"> <... variable-n <"text-n">>;
NMVAR variable-1 <"text-1"> <... variable-n <"text-n">>;
NOTES "text";
TEXT header-specification;
TEXT2 header-specification;
TEXT3 header-specification;
END;

DEFINE HEADER Statements
Task Statement
Set one or more header attributes header-attribute(s)
Define a symbol that references a value that the data component supplies from the procedure or DATA step DYNAMIC
Define a symbol that references a macro variable. ODS will use the variable as a string. References to the macro variable are resolved when ODS binds the template and the data component to produce an output object. MVAR
Define a symbol that references a macro variable. ODS will convert the variable's value to a number (stored as a double) before using it. References to the macro variable are resolved when ODS binds the template and the data component to produce an output object. NMVAR
Provide information about the column NOTES
Specify the text of the header TEXT
Specify an alternative header to use in the listing output if the header that is provided by the TEXT statement is too long TEXT2
Specify an alternative header to use in the listing output if the header that is provided by the TEXT2 statement is too long TEXT3
End the header template 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.

Restriction: If the template is nested inside of another template, header-path must be a single-level name.
Restriction: 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. Once 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.
Featured in: Creating Master Templates

Options

STORE=libref.template-store

specifies the template store in which to store the template. If the template store does not exist, it is created.

Restriction: 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.
Restriction: 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 kinds 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 DEF_SPLIT All
Specify whether to try to expand the column width to accommodate the longest word in the column header FORCE LISTING
Specify the horizontal justification for the column header JUST= 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 MAXIMIZE LISTING
Specify whether to draw a continuous line above the header OVERLINE LISTING
Specify whether to treat the text as preformatted text PREFORMATTED Markup family, printer family, and RTF
Specify whether to print the header PRINT 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 SPACE= LISTING
Specify the split character for the header SPLIT= All except OUTPUT
Specify the style element and any changes to its attributes to use for the header STYLE= Markup family, printer family, and RTF
Specify whether to start a new header line in the middle of a word TRUNCATE LISTING
Specify whether to draw a continuous line underneath the header UNDERLINE LISTING
Specify vertical justification for the header VJUST= Markup family, PRINTER, family, and RTF
Specify the width of the header in characters WIDTH= 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 EXPAND= LISTING
Specify whether to repeat the text of the header until the space that is allotted for the header is filled REPEAT LISTING
Influence the placement of the header

Specify the last column that a spanning header covers END= All except OUTPUT
Specify the first column that a spanning header covers START= All except OUTPUT
Specify whether to expand the header to reach the sides of the page EXPAND_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 FIRST_PANEL 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 LAST_PANEL LISTING, printer family, and RTF
Specify whether to extend the text of the header into the header space of adjacent columns SPILL_ADJ LISTING
Specify whether to extend the text of the header into the adjacent margin SPILL_MARGIN LISTING
Other header attributes

Specify an abbreviation for the header * ABBR= MARKUP
Specify an acronym for the header * ACRONYM= MARKUP
Specify an alternate description for the header * ALT= MARKUP
Specify whether multiple columns can use the header GENERIC All except OUTPUT
Specify a long description for the header * LONGDESC= MARKUP
Specify the header template that the current template inherits from PARENT= All
* SAS 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.

Requirement: The text must be enclosed with quotation marks.
Tip: The ABBR attribute is valid only in the MARKUP destination.

Note:   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.  [cautionend]

ACRONYM= "text" | variable

specifies an acronym for the header.

Requirement: The text must be enclosed with quotation marks.
Tip: The ACRONYM= attribute is valid only in the MARKUP destination.

Note:   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.  [cautionend]

ALT= "text" | variable

specifies an alternate description of the header.

Requirement: The text must be enclosed with quotation marks.
Tip: The ALT= attribute is valid only in the MARKUP destination.

Note:   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.  [cautionend]

DEF_SPLIT

specifies which 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
See also: START=
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.
See also: REPEAT=
Tip: If the string or the variable that you specify contains more than one character, then only the first character is used.
Tip: The EXPAND= attribute is valid only in the LISTING destination.
See also: EXPAND_PAGE=
EXPAND_PAGE<= ON | OFF | variable>

specifies whether to expand the header to reach the sides of the page.

Default: OFF
See also: EXPAND=
Tip: The EXPAND_PAGE attribute is valid only in the LISTING destination.
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
See also: LAST_PANEL=
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
See also: WIDTH and WIDTH_MAX
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.
Featured in: Editing a Table Template That a SAS Procedure Uses
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
See also: FIRST_PANEL
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.

Requirement: The text must be enclosed within quotation marks.
Tip: The LONGDESC= attribute is valid only in markup family destinations.

Note:   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.  [cautionend]

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 the FORMCHAR= attribute.)

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
Interaction: 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
Tip: 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.
Tip: 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.
See also: EXPAND=
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
Tip: A row of underlining or overlining is considered a header or a footer.
Tip: The SPACE= attribute is valid only in the LISTING destination.
Featured in: Creating a New Table Template
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=.
See also: The FORCE= header attribute, the SPILL_MARGIN= header attribute, and the TRUNCATE= header attribute
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=.
See also: The FORCE= header attribute, the SPILL_ADJ header attribute, and the TRUNCATE= header attribute
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.

Tip: The first character in a header is automatically treated as a split character if it is not one of the following:

  • an alphanumeric character

  • a blank

  • an underscore (_)

  • a hyphen (-).

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
See also: END
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.

Default: Header
See also: Viewing the Contents of a Style
See also: Working with Styles
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.
Tip: You can use braces ({ and }) instead of square brackets ([ and ]).
Tip: 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.
Tip: The STYLE= attribute is valid only in the markup family, printer family, and RTF destinations.
Featured in: Editing a Table Template That a SAS Procedure Uses and Creating a New Table Template
See also: Style Attributes and Their Values
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.

Note:   TRUNCATE=OFF is the same as FORCE=ON.  [cautionend]

Default: OFF
Interaction: If you specify FORCE=, SPILL_MARGIN=, or SPILL_ADJ=, then the TRUNCATE= attribute is ignored.
See also: The FORCE= header attribute, the SPILL_MARGIN= header attribute, and the SPILL_ADJ header attribute
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
Main discussion: See the discussion of the FORMCHAR= attribute.
Tip: The UNDERLINE attribute is valid only in the LISTING destination.
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.
Tip: To create a vertical header, specify a width of 1.
Tip: The WIDTH= attribute is valid only in the LISTING destination.

DYNAMIC Statement


Defines a symbol that references a value that the data component supplies from the procedure or DATA step.
Scope: You can use the DYNAMIC statement in the template of a table, column, header, or footer. A dynamic variable that is defined in a template is available to that template and to all the templates that it contains.
Featured in: Creating a Stand-Alone Style and Using User-Defined Attributes

DYNAMIC variable-1 <'text-1'> <... variable-n <'text-n'>>;

Required Arguments

variable

names a variable that the data component supplies. ODS resolves the value of the variable when it binds the template and the data component.

Tip: Dynamic variables are most useful to the authors of SAS procedures and to DATA step programmers.

Options

text

is text that is placed in the template to explain the dynamic variable's use. Text of this type becomes part of the compiled template, which you can view with the SOURCE statement, whereas SAS comments do not.


MVAR Statement


Defines a symbol that references a macro variable. ODS will use the value of the variable as a string. References to the macro variable are resolved when ODS binds the template and the data component to produce an output object.
Scope: You can use the MVAR statement in the template of a table, column, header, or footer. A macro variable that is defined in a template is available to that template and to all the templates that it contains.
Featured in: Creating a New Table Template and Creating a Stand-Alone Style

MVAR variable-1 <'text-1'> <... variable-n <'text-n'>>;


Required Arguments

variable

names a macro variable to reference in the template. ODS will use the value of the macro variable as a string. ODS does not resolve the value of the macro variable until it binds the template and the data component.

Tip: Declare macro variables this way in a template. For example, to use the automatic macro variable SYSDATE9 in a template, declare it in an MVAR statement and reference it as SYSDATE9, without an ampersand, in the PROC TEMPLATE step. If you use the ampersand, the macro variable resolves when the template is compiled instead of when ODS binds the template to the data component.

Options

text

is text that is placed in the template to explain the macro variable's use. Text of this type becomes part of the compiled template, which you can view with the SOURCE statement, whereas SAS comments do not.


NMVAR Statement


Defines a symbol that references a macro variable. ODS will convert the variable's value to a number (stored as a double) before using it. References to the macro variable are resolved when ODS binds the template and the data component to produce an output object.
Scope: You can use the NMVAR statement in the template of a table, column, header, or footer. A macro variable that is defined in a template is available to that template and to all the templates that it contains.
Featured in: Setting the Style Element for Cells Based on Their Values

NMVAR variable-1 <'text-1'> <... variable-n <'text-n'>>;


Required Arguments

variable

names a macro variable to reference in the template. ODS will convert the variable's value to a number (stored as a double) before using it. ODS does not resolve the macro variable until it binds the template and the data component.

Tip: Declare macro variables this way in a template. For example, to use a macro variable as a number, declare it in an NMVAR statement and reference it without an ampersand. If you use the ampersand, the macro variable resolves when the template is compiled instead of when ODS binds the template to the data component.

Options

text

is text that is placed in the template to explain the macro variable's use. Text of this type becomes part of the compiled template, which you can view with the SOURCE statement, whereas SAS comments do not.


NOTES Statement


Provides information about the table, header, column, or footer.
Tip: The NOTES statement becomes part of the compiled template, which you can view with the SOURCE statement, whereas SAS comments do not.
Featured in: Setting the Style Element for Cells Based on Their Values

NOTES 'text';

Required Arguments

text

provides information about the table.


TEXT Statement


Specifies the text of the header or the label of a variable in an output data set.
Featured in: Creating a New Table Template

TEXT header-specification(s);


Required Arguments

header-specification(s)

specifies the text of the header. Each header-specification is one of the following:

_LABEL_

uses the label of the object that the header applies to as the text of the header. For example, if the header is for a column, _LABEL_ specifies the label for the variable that is associated with the column. If the header is for a table, _LABEL_ specifies the label for the data set that is associated with the table.

text-specification(s)

specifies the text to use in the header. Each text-specification is one of the following:

  • a quoted string

  • a variable, followed by an optional format. The variable is any variable that is declared in a DYNAMIC, MVAR, or NMVAR statement.

Note:   If the first character in a quoted string is neither a blank character nor an alphanumeric character, and SPLIT is not in effect, the TEXT statement treats that character as the split character. (See the discussion of SPLIT.)  [cautionend]

Default: If you omit a TEXT statement, the text of the header is the label of the object that the header applies to.
Tip: If the quoted string is a blank and it is the only item in the header specification, the header is a blank line.
Featured in: Creating a New Table Template

TEXT2 Statement


Provides an alternative header to use in the listing output if the header that is provided by the TEXT statement is too long.
See: TEXT Statement


TEXT3 Statement


Provides an alternative header to use in the listing output if the header that is provided by the TEXT2 statement is too long.
See: TEXT Statement


END Statement


Ends the table template, header template, column template, or footer template.
END;

Previous Page | Next Page | Top of Page