TEMPLATE Procedure: Creating Table Templates

DEFINE TABLE Statement

Creates a table template.
Requirement: An END statement must be the last statement in the template.
Interaction: A table template can contain one or more column, header, or footer templates.
Creating a New Table Template

Setting the Style Element for Cells Based on Their Values

Syntax

DEFINE TABLE table-path | Base.Template.Table
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] >
<, expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
COLUMN column(s);
DEFINE template-type template-name </ option(s)>;
statements-and-attributes
END;
DYNAMIC variable-1 <=default-variable-1>
<'text-1'> <... variable-n <=default-variable-n><'text-n'>>;
FOOTER footer-name(s);
HEADER header-name(s);
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";
TRANSLATE expression-1 INTO expression-2 < , expression-n INTO expression-m;>
END;

Required Arguments

table-path
specifies where to store the table template. A table-path consists of one or more names that are separated by periods. Each name represents a directory in a template store, which is a type of SAS file. PROC TEMPLATE writes the template to the first writable template store in the current path.
Base.Template.Table
creates a master table 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.Table master template attributes are overridden by other table templates.
Tip:The Base.Template.Table master template is most useful when used with the CELLSTYLE AS statements to create alternating colors in your tabular output.

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.
Restriction:The STORE= option does not become part of the template.

Table Attribute Statements

This section lists all the attributes that you can use in a table template. 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_
1
0
TRUE
FALSE
YES
NO
_YES_
_NO_
Table Attributes
Task
Attribute
Destinations
Influence the layout of the table
Specify whether to try to place the same number of columns in each data panel if the entire table does not fit in one data panel
LISTING, printer family, and RTF
Specify whether to center each data panel independently if the entire table does not fit in one data panel
LISTING, printer family, RTF
Specify whether to force a new page before printing the table
All except OUTPUT
Specify the number of sets of columns to place on a page
LISTING and printer family
Specify the number of blank characters to place between sets of columns when PANELS= is in effect
LISTING
Specify the number of lines that must be available on the page in order to print the body of the table
LISTING and printer family
Specify the number of lines to place between the previous output object and the current one
LISTING and printer family
Specify whether to split a table that is too wide to fit in the space that is provided or to wrap each row of the table
LISTING and printer family
Specify whether to add a double space after the last line of a single row when the row is wrapped
LISTING and printer family
Influence the layout of rows and columns
Specify the maximum number of blank characters to place between columns
LISTING
Specify the minimum number of blank characters to place between columns
LISTING
Specify the name of the column whose value provides formatting information about the space before each row of the template
All except OUTPUT
Specify whether to double space between the rows of the table
LISTING
Specify whether extra space is evenly divided among all columns of the table
LISTING
Specify whether to split a long stacked column across page boundaries
LISTING
Influence the display of the values in header cells and data cells
Specify whether to suppress blanking the value in a column that is marked with the BLANK_DUPS column attribute if the value changes in a previous column that is also marked with the BLANK_DUPS attribute
LISTING and printer family
Specify which format to use if both a column template and a data component specify a format
All
Specify whether to justify the format fields within the columns or to justify the values within the columns without regard to the format fields
LISTING
Specify whether to order the columns by their order in the data component
All except OUTPUT
Specify the source of the values for the format width and the decimal width if they are not specified
All
Use the column name as the column header if neither the column template nor the data component specifies a header
All
Influence the layout of headers and footers
Specify the number of blank lines to place between the last row of data and the first row of output
LISTING
Specify the number of blank lines to place between the last row of headers and the first row of data
LISTING
Specify whether to draw a continuous line above the first table footer or, if there is no table footer, below the last row of data on a page
LISTING
Specify whether to print table footers and any overlining of the table footers
All except OUTPUT
Specify whether to print table headers and any underlining of the table headers
All except OUTPUT
Specify whether to draw a continuous line under the last table header or, if there is no table header, then above the last row of data on a page
LISTING
Influence the non-LISTING output
Specify whether to place the output object in a table of contents, if you create a table of contents
HTML
Specify the label to use for the output object in the contents file, the Results window, and the trace record
HTML, PDF, PRINTER, PS PDFMARK
Other table attributes
Specify an alternate description for the table1
MARKUP
Control whether BY lines are printed above each BY group
All except OUTPUT
Define the characters to use as the line-drawing characters in the table
LISTING
Specify a label for the table
All
Specify a long description for the table1
MARKUP
Specify the table that the current template inherits from
All
Specify the style element to use for the table and any changes to the attributes
Markup family, printer family, and RTF
Specify the special data set type of a SAS data set
OUTPUT
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.
ALT= "text";
specifies an alternate description of the table. 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 markup family destinations.
BALANCE <=ON | OFF | variable>;
specifies whether to try to place the same number of columns in each data panel if the entire table does not fit in one data panel.
Default:OFF
Tip:The BALANCE attribute is valid only in the LISTING, printer family, and RTF
BYLINE <=ON | OFF | variable>;
controls whether BY lines are printed above each BY group in a configuration file, SAS invocation, OPTIONS statement, or Systems Options window.
Category:PROC OPTIONS GROUP= LISTCONTROL
Default:OFF
Restriction:This attribute applies only if the table is not the first one on the page. If BY-group processing is in effect, a byline automatically precedes the first table on the page.
Tip:The BYLINE attribute is valid in all destinations except the OUTPUT destination.
CENTER <=ON | OFF | variable>;
specifies whether to center each data panel independently if the entire table does not fit in the space that is provided.
Default:ON
Tip:The CENTER attribute is valid only in the LISTING, printer family, and RTF destinations.
CLASSLEVELS <=ON | OFF | variable>;
specifies whether to suppress blanking the value in a column that is marked with the BLANK_DUPS column attribute if the value changes in a previous column that is also marked with the BLANK_DUPS attribute.
Default:OFF
Tip:The CLASSLEVELS attribute is valid for all destinations except the OUTPUT destination.
COL_SPACE_MAX= positive-integer | variable;
specifies the maximum number of blank characters to place between the columns.
Default:4
Tip:The COL_SPACE_MAX= table attribute is valid only in the LISTING destination.
COL_SPACE_MIN= positive-integer | variable;
specifies the minimum number of blank characters to place between the columns.
Default:2
Tip:The COL_SPACE_MIN= attribute is valid only in the LISTING destination.
CONTENTS <=ON | OFF | variable>;
specifies whether to place the output object in a table of contents, if you create a table of contents.
Default:ON
Tip:The CONTENTS attribute is valid in markup family and printer family destinations.
CONTENTS_LABEL= "string" | variable;
specifies the label to use for the output object in the contents file, the Results window, and the trace record.
Default:If the SAS system option LABEL is in effect, the default label is the object's label. If LABEL is not in effect, the default label is the object's name.
Tip:The CONTENTS_LABEL= attribute is valid only in markup family and printer family destinations.
CONTROL=column-name | variable;
specifies the name of the column whose values provide formatting information about the space before each row of the template. The value of CONTROL= should be the name of a column of type character with a length equal to 1.
Values in the Control Column
Column Control Value
Result
A digit from 1-9
The specified number of blank lines precedes the current row.
A hyphen (-)
A row of underlining precedes the current row.
"b" or "B"
ODS tries to insert a panel break if the entire table does not fit in the space that is provided.
Default:None
Tip:The CONTROL= attribute is valid in all destinations except the OUTPUT destination.
DATA_FORMAT_OVERRIDE<=ON | OFF | variable>;
specifies which format to use if both a column template and a data component specify a format.
ON
uses the format that the data component specifies.
OFF
use the format that the column template specifies.
Default:OFF
Tip:The DATA_FORMAT_OVERRIDE attribute is valid in all destinations.
DOUBLE_SPACE<=ON | OFF | variable>;
specifies whether to double space between the rows of the table.
Default:OFF
Tip:The DOUBLE_SPACE attribute is valid only in the LISTING destination.
EVEN<=ON | OFF | variable>;
specifies whether extra space is evenly divided among all columns of the table.
Default:OFF
Tip:The EVEN attribute is valid only in the LISTING destination.LISTING
FOOTER_SPACE=0 | 1 | 2 | variable;
specifies the number of blank lines to place between the last row of data and the first row of the table footer.
Default:1
Tip:The FOOTER_SPACE= attribute is valid only in the LISTING destination.
FORMCHAR= "string" | variable;
defines the characters to use as the line-drawing characters in the table. Currently, ODS uses only the second of the 20 possible formatting characters. This formatting character is used for underlining and overlining. To change the second formatting character, specify both the first and second formatting characters. For example, this option assigns the asterisk (*) to the first formatting character, the plus sign (+) to the second character, and does not alter the remaining characters: formchar="*+"
Default:The SAS system option FORMCHAR= specifies the default formatting characters.
Tips:Use any character in formatting-characters, including hexadecimal characters. If you use hexadecimal characters, then put an x after the closing quotation mark. For example, this option assigns the hexadecimal character 2-D to the first formatting character, the hexadecimal character 7C to the second character, and does not alter the remaining characters: formchar="2D7C"x

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

HEADER_SPACE=0 | 1 | 2 | variable;
specifies the number of blank lines to place between the last row of headers and the first row of data. A row of underscores is a header.
Default:1
Tip:The HEADER_SPACE= attribute is valid only in the LISTING destination.
JUSTIFY<=ON | OFF | variable>;
specifies whether to justify the format fields within the columns or to justify the values within the columns without regard to the format fields.
Default:OFF
Interactions:JUSTIFY=ON can interfere with decimal alignment.

If the column is numeric, then values are aligned to the right if you specify JUSTIFY=OFF and JUST=C.

All of the destinations except for the LISTING destination justify the values in columns as if JUSTIFY=ON for JUST=R and JUST=L.

Tips:If you translate numeric data to character data, you might need to use JUSTIFY= to align the data.

The JUSTIFY attribute is valid only in the LISTING destination.

LABEL= "text" | variable;
specifies a label for the table.
Default:ODS uses the first of the following that it finds: a label that the table template provides, a label that the data component provides, or the first spanning header in the table.
Tip:The LABEL= attribute is valid in all destinations.
LONGDESC= "string";
specifies the long description of the table. 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 LONGDESC= attribute is valid only in markup family destinations.
NEWPAGE<=ON | OFF | variable>;
specifies whether to force a new page before printing the table.
Default:OFF
Restriction:If the table is the first item on the page, ODS ignores this attribute.
Tip:The NEWPAGE attribute is valid in all destinations except the OUTPUT destination.
ORDER_DATA<=ON | OFF | variable>;
specifies whether to order the columns by their order in the data component.
Default:OFF

When ORDER_DATA=OFF, the default order for columns is the order that they are specified in the COLUMN statement. If you omit a COLUMN statement, the default order for columns is the order in which you define them in the template.

Interaction:ORDER_DATA is most useful for ordering generic columns.
Tip:The ORDER_DATA attribute is valid in all destinations except the OUTPUT destination. The OUTPUT destination always uses the order of the columns in the data component when it creates an output data set.
OVERLINE<=ON | OFF | variable>;
specifies whether to draw a continuous line above the first table footer or, if there is no table footer, below the last row of data on a page. The second formatting character is used to draw the line.
Default:OFF
Tip:The OVERLINE attribute is valid only in the LISTING destination.
See:For information about formatting characters, see the discussion of FORMCHAR= "string" | variable;.

UNDERLINE= table attribute, UNDERLINE= column attribute, and the OVERLINE= column attribute.

PANELS=positive-integer | variable;
specifies the number of sets of columns to place on a page. If the width of all the columns is less than half of the line size, display the data in multiple sets of columns so that rows that would otherwise appear on multiple pages appear on the same page.
Tips:If the number of panels that is specified is larger than the number of panels that can fit on the page, the template creates as many panels as it can. Let the table template put data in the maximum number of panels that can fit on the page by specifying a large number of panels (for example, 99).

The PANELS= attribute is valid only in LISTING and printer family destinations.

PANEL_SPACE=positive-integer | variable;
specifies the number of blank characters to place between sets of columns when PANELS= is in effect.
Default:2
Tip:The PANEL_SPACE= attribute is valid only in the LISTING destination.
PARENT=table-path;
specifies the table that the current template inherits from. A table-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 table in the first template store in the current path that you can read from.
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 overrides them.
Tip:The PARENT= attribute is valid in all destinations.
PRINT_FOOTERS<=ON | OFF | variable>;
specifies whether to print table footers and any overlining of the table footers.
Default:ON
Tip:The PRINT_FOOTERS attribute is valid in all destinations except the OUTPUT destination.
PRINT_HEADERS<=ON | OFF | variable>;
specifies whether to print the table headers and any underlining of the table headers.
Default:ON
Interaction:When used in a table template, PRINT_HEADERS affects only headers for the table, not the headers for individual columns. For individual columns, use the following column attribute: PRINT_HEADERS<=ON | OFF | variable>;.
Tip:The PRINT_HEADERS attribute is valid in all destinations except the OUTPUT destination.
REQUIRED_SPACE=positive-integer | variable;
specifies the number of lines that must be available on the page in order to print the body of the table. The body of the table is the part of the table that contains the data. It does not include headers and footers.
Default:3
Tip:The REQUIRED_SPACE= attribute is valid in LISTING and printer family destinations.
SPLIT_STACK<=ON | OFF | variable>;
specifies whether to split a long stacked column across page boundaries.
Default:OFF
Tip:The SPLIT_STACK attribute is valid only in the LISTING destinations.
STYLE=<style-element-name><[style-attribute-specification(s)]>;
specifies the style element and any changes to its attributes to use for the table.
style-element-name
is the name of the style element to use to display the table. 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 with PROC TEMPLATE (see DEFINE STYLE Statement). By default, ODS produces different parts of ODS output with different elements. For example, by default, a table is produced with the style element Table. The styles that SAS provides do not provide another style element that you would be likely to want to use instead of Table. However, you might have a user-defined style element at your site that would be appropriate to specify.
The style element provides the basis for displaying the table. 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
Default:Table
Requirement:Specify either a style-attribute-specification or a style-element-name with the STYLE= option.
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.

TOP_SPACE=positive-integer | variable ;
specifies the number of lines to place between the previous output object and the current one.
Default:1
Tip:The TOP_SPACE= attribute is valid only in LISTING and printer family destinations.
TYPE=string | variable;
specifies special type of SAS data set.
Restriction:PROC TEMPLATE does not verify that a SAS data set type that you specify is a valid data set type or the structure of the data set that you create is appropriate for the type that you have assigned.
Tips:Most SAS data sets have no special type. However, certain SAS procedures, like the CORR procedure, can create a number of special SAS data sets. In addition, SAS/STAT software and SAS/EIS software support special data set types.

The TYPE= attribute is valid only in the OUTPUT destination.

UNDERLINE<=ON | OFF | variable>;
specifies whether to draw a continuous line under the last table header (or, if there is no table header, then above the first row of data on a page). 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 FORMCHAR= "string" | variable;.

UNDERLINE= column attribute and OVERLINE= column attribute.

Also see OVERLINE table attribute.

USE_FORMAT_DEFAULTS<=ON | OFF | variable>;
specifies the source of the values for the format width and the decimal width if they are not specified.
ON
uses the default values, if any, that are associated with the format name.
OFF
uses the PROC TEMPLATE defaults.
Default:OFF
Tip:The USE_FORMAT_DEFAULTS attribute is valid in all destinations except the OUTPUT destination.
USE_NAME<=ON | OFF | variable>;
uses the column name as the column header if neither the column template nor the data component specifies a header.
Default:OFF
Tips:Use this attribute when column names are derived from a data set and the columns are generic.

The USE_NAME attribute is valid in all destinations except the OUTPUT destination.

WRAP<=ON | OFF | variable>;
specifies whether to split a wide table into multiple data panels, or to wrap each row of the table so that an entire row is printed before the next row starts.
Default:OFF
Interaction:When ODS wraps the rows of a table, it does not place multiple values in any column that contains an ID column.
Tip:The WRAP attribute is valid only in LISTING and printer family destinations.
WRAP_SPACE<=ON | OFF | variable>
specifies whether to double space after the last line of a single row of the table when the row is wrapped onto more than one line.
Default:OFF
Tip:The WRAP_SPACE attribute is valid only in the LISTING, printer family, and RTF destinations.