Previous Page | Next Page

TEMPLATE Procedure: Creating Tabular Output

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.
Featured in: Creating a New Table Template and Setting the Style Element for Cells Based on Their Values

DEFINE TABLE table-path | Base.Template.Table
</ STORE=libref.template-store>;
<table-attribute-1; <... table-attribute-n; >>
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 <"text-1"> <... variable-n <"text-n">>;
FOOTER footer-name(s);
HEADER header-name(s);
MVAR variable-1 <"text-1"> <... variable-n <"text-n">>;
NMVAR variable-1 <"text-1"> <... variable-n <"text-n">>;
NOTES "text";
TRANSLATE expression-1 INTO expression-2 <... , expression-n INTO expression-m;>
END;

DEFINE TABLE Statements
Task Statement
Set one or more table attributes table-attribute(s)
Set the style element of the cells in the table that contain numeric variables according to the values of the variables CELLSTYLE AS
Declare a symbol as a column in the table and specify the order of the columns COLUMN
Create a template for a column, header, or footer DEFINE
Define a symbol that references a value that the data component supplies from the procedure or DATA step DYNAMIC
Declare a symbol as a footer in the table and specify the order of the footers FOOTER


Declare a symbol as a header in the table and specify the order of the headers HEADER
Define 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. MVAR
Define a symbol that references a macro variable. ODS will convert the value of the variable to a number (stored as a double) before use. 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 table NOTES
Translate the specified numeric values to other values TRANSLATE INTO
End a template, or end the editing of a template 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.
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: The STORE= option does not become part of the template.

Table Attributes

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 BALANCE LISTING, printer family, and RTF
Specify whether to center each data panel independently if the entire table does not fit in one data panel CENTER LISTING, printer family, RTF
Specify whether to force a new page before printing the table NEWPAGE All except OUTPUT
Specify the number of sets of columns to place on a page PANELS= LISTING and printer family
Specify the number of blank characters to place between sets of columns when PANELS= is in effect PANEL_SPACE= LISTING
Specify the number of lines that must be available on the page in order to print the body of the table REQUIRED_SPACE= LISTING and printer family
Specify the number of lines to place between the previous output object and the current one TOP_SPACE= 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 WRAP LISTING and printer family
Specify whether to add a double space after the last line of a single row when the row is wrapped WRAP_SPACE LISTING and printer family
Influence the layout of rows and columns

Specify the maximum number of blank characters to place between columns COL_SPACE_MAX= LISTING
Specify the minimum number of blank characters to place between columns COL_SPACE_MIN= LISTING
Specify the name of the column whose value provides formatting information about the space before each row of the template CONTROL= All except OUTPUT
Specify whether to double space between the rows of the table DOUBLE_SPACE LISTING
Specify whether extra space is evenly divided among all columns of the table EVEN LISTING
Specify whether to split a long stacked column across page boundaries SPLIT_STACK 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 CLASSLEVELS= LISTING and printer family
Specify which format to use if both a column template and a data component specify a format DATA_FORMAT_OVERRIDE 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 JUSTIFY LISTING
Specify whether to order the columns by their order in the data component ORDER_DATA All except OUTPUT
Specify the source of the values for the format width and the decimal width if they are not specified USE_FORMAT_DEFAULTS All
Use the column name as the column header if neither the column template nor the data component specifies a header USE_NAME 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 FOOTER_SPACE= LISTING
Specify the number of blank lines to place between the last row of headers and the first row of data HEADER_SPACE= 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 OVERLINE LISTING
Specify whether to print table footers and any overlining of the table footers PRINT_FOOTERS All except OUTPUT
Specify whether to print table headers and any underlining of the table headers PRINT_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 UNDERLINE LISTING
Influence the HTML output

Specify whether to place the output object in a table of contents, if you create a table of contents CONTENTS HTML
Specify the label to use for the output object in the contents file, the Results window, and the trace record CONTENTS_LABEL= HTML, PDF, PRINTER, PS PDFMARK
Other table attributes

Specify an alternate description for the table * ALT= MARKUP
Control whether BY lines are printed above each BY group BYLINE= All except OUTPUT
Define the characters to use as the line-drawing characters in the table FORMCHAR= LISTING
Specify a label for the table LABEL= All
Specify a long description for the table * LONGDESC= MARKUP
Specify the table that the current template inherits from PARENT= All
Specify the style element to use for the table and any changes to the attributes STYLE= Markup family, printer family, and RTF
Specify the special data set type of a SAS data set TYPE= OUTPUT
* 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.

ALT= "text"

specifies an alternate description of the table.

Requirement: The text must be enclosed with quotation marks.
Tip: The ALT= 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]

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.
Featured in: Creating a Stand-Alone Style
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.
Featured in: Editing a Table Template That a SAS Procedure Uses and Creating a New Table Template
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.
Tip: Use any character in formatting-characters, including hexadecimal characters. If you use hexadecimal characters, then put an x after the closing quote. For example, this option assigns the hexadecimal character 2D to the first formatting character, the hexadecimal character 7C to the second character, and does not alter the remaining characters:
formchar="2D7C"x
Tip: 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
Interaction: JUSTIFY=ON can interfere with decimal alignment.
Interaction: If the column is numeric, then values are aligned to the right if you specify JUSTIFY=OFF and JUST=C.
Interaction: All of the destinations except for the LISTING destination justify the values in columns as if JUSTIFY=ON for JUST=R and JUST=L.
Tip: If you translate numeric data to character data, you might need to use JUSTIFY= to align the data.
Main discussion: Values in Table Columns and How They Are Justified
Tip: 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

  • 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.

Requirement: The text must be enclosed with 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]

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
Main discussion: See the discussion of the FORMCHAR= attribute.
See also: UNDERLINE= (for tables), UNDERLINE= (for columns), and OVERLINE= (for columns)
Tip: The OVERLINE attribute is valid only in the LISTING destination.
Featured in: Editing a Table Template That a SAS Procedure Uses
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 linesize, display the data in multiple sets of columns so that rows that would otherwise appear on multiple pages appear on the same page.

Tip: 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).
Tip: 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
See also: OVERLINE=
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. (See the discussion of the PRINT_HEADERS column attribute .)
Tip: The PRINT_HEADERS attribute is valid in all destinations except the OUTPUT destination.
See also: UNDERLINE=
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.

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
See also: Style Attributes and Their Values
Default: Table
Requirement: Specify either a style-attribute-specification or a style-element-name with the STYLE= option.
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.
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 the following:

  • a SAS data set type that you specify is a valid data set type

  • the structure of the data set that you create is appropriate for the type that you have assigned

Tip: 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.
Tip: 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
Main discussion: See the discussion of the FORMCHAR= attribute
See also: OVERLINE= (for tables) , UNDERLINE (for columns), and OVERLINE (for columns)
Tip: The UNDERLINE attribute is valid only in the LISTING destination.
Featured in: Editing a Table Template That a SAS Procedure Uses and Creating a New Table Template
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
Tip: Use this attribute when column names are derived from a data set and the columns are generic.
Tip: 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.
See also: WRAP_SPACE= and ID=
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
See also: WRAP=
Tip: The WRAP_SPACE attribute is valid only in the LISTING, printer family, and RTF destinations.

CELLSTYLE-AS Statement


Sets the style element of the cells in the table according to the values of the variables. Use this statement to set the presentation characteristics (such as foreground color and font face) of individual cells.
Featured in: Setting the Style Element for Cells Based on Their Values

CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)]> <..., expression-n AS <style-element-name><[style-attribute-specification(s)]>>;


Required Arguments

expression

is an expression that is evaluated for each table cell that contains a variable.

If expression resolves to TRUE (a non-zero value), the style element that is specified is used for the current cell. If expression is FALSE (zero), the next expression in the statement is evaluated. Thus, you can string multiple expressions together to format cells conditionally.

expression has this form:

expression-1 <comparison-operator expression-n>

expression

is an arithmetic or logical expression that consists of a sequence of operators and operands. An operator is a symbol that requests a comparison, logical operation, or arithmetic calculation. An operand is one of the following:

constant

is a fixed value such as the name of a column or symbols that are declared in a DYNAMIC, MVAR, or NMVAR statement in the current template.

SAS function

specifies a SAS function. For information on SAS functions, see SAS Language Reference: Dictionary.

Built-in variable

is a special kind of WHERE expression operand that helps you find common values in table templates. Built-in variables are one or more of the following:

_COLUMN_

is a column number. Column numbering begins with 1.

Alias: _COL_
Featured in: Setting the Style Element for a Specific Column, Row, and Cell
_DATANAME_

is a data column name.

_DATATYPE_

is the data type of the column variable. The data type is either numeric ("num") or character ("char").

Example: The following CELLSTYLE AS statement specifies that numeric column variables have a red font color and character column variables have a blue font color:
    cellstyle   _datatype_ = "num" as {color=red}, 
                 _datatype_ = "char" as {color=blue};
_LABEL_

is a column label.

Featured in: Setting the Style Element for a Specific Column, Row, and Cell
_ROW_

is a row number. Row numbering begins with 1.

Featured in: Setting the Style Element for a Specific Column, Row, and Cell
_STYLE_

is a style element name.

Featured in: Creating Master Templates
_VAL_

is the data value of a cell.

Tip: Use _VAL_ to represent the value of the current column.
Featured in: Creating Master Templates
comparison-operator

compares a variable with a value or with another variable. The following table lists the comparison operators:

Comparison Operators
Symbol Mnemonic Equivalent Definition
= EQ Equal to
^= or ~= or ¬= or <> NE Not equal to
> GT Greater than
< LT Less than
>= GE Greater than or equal to
<= LE Less than or equal to

IN Equal to one from a list of values

Featured in: Setting the Style Element for a Specific Column, Row, and Cell
Tip: Using an expression of 1 as the last expression in the CELLSTYLE AS statement sets the style element for any cells that did not meet an earlier condition.
See also: You can use any expression that can be used in the WHERE= data set option. For information on expressions that you can use in the WHERE data set option, see the WHERE data set option in SAS Language Reference: Dictionary and "WHERE Expression Processing" in SAS Language Reference: Concepts.
style-attribute-specification

describes a style attribute to set. Each style-attribute-specification has this general form:

style-attribute-name=style-attribute-value

For information on the style attributes that you can set in a table template, see Style Attributes and Their Values.


Options

style-element-name

is the name of a style element that is part of a style that is registered with the Output Delivery System. SAS provides some styles. You can create customized styles and style elements with PROC TEMPLATE. (See DEFINE STYLE Statement.)

The style elements that you would be most likely to use with the CELLSTYLE AS statement are

  • Data

  • DataFixed

  • DataEmpty

  • DataEmphasis

  • DataEmphasisFixed

  • DataStrong

  • DataStrongFixed

The style element provides the basis for displaying the cell. Additional style attributes modify the display.


COLUMN Statement


Declares a symbol as a column in the table and specifies the order of the columns.
Featured in: Creating a New Table Template

COLUMN column(s);


Required Arguments

column

is one or more columns. If the column is defined outside the current table template, reference it by its path in the template store. Columns in the template are laid out from left to right in the same order that they are specified in the COLUMN statement.

Default: If you omit a COLUMN statement, ODS makes a column for each column template (DEFINE COLUMN statement), and places the columns in the same order that the column templates have in the table template.

If you use a COLUMN statement but omit a DEFINE COLUMN statement for any of the columns, ODS uses a default column template that is based on the type of data in the column.

Interaction: If you specify the column attribute PRINT=OFF, then the value of a column is turned off if the column is part of a stacked column. If all columns in a stacked column have PRINT=OFF set, then the entire column is removed from the table.
Tip: Use a list of variable names, such as DAY1-DAY10, to specify multiple variables.
Main discussion: Stacking Values for Two or More Variables

To stack values for two or more variables in the same column, put parentheses around the stacked variables. In such a case, the column header for the first column inside the parentheses becomes the header for the column that contains all the variables inside parentheses. For example, this COLUMN statement produces a template with the following characteristics:

  • The value of NAME is in the first column by itself.

  • The values of CITY and STATE appear in the second column with CITY above STATE. The header for this column is the header that is associated with CITY.

  • The values HOMEPHONE and WORKPHONE appear in the third column with HOMEPHONE above WORKPHONE. The header for this column is the header that is associated with HOMEPHONE.

    column name (city state) (homephone workphone);

Use the asterisk (*) in the COLUMN statement to change the layout of stacking variables. An asterisk between groups of variables in parentheses stacks the first item in the first set of parentheses above the first item in the next set of parentheses, and so on until the last group of parentheses is reached. Then, the second item in the first group is stacked above the second item in the second group, and so on. For example, this COLUMN statement produces a report with the following characteristics:

  • The value of NAME is in the first column by itself.

  • The values of CITY and HOMEPHONE appear in the second column with CITY above HOMEPHONE. The header for this column is the header that is associated with CITY.

  • The values STATE and WORKPHONE appear in the third column with STATE above WORKPHONE. The header for this column is the header that is associated with STATE.

    column name (city state) * (homephone workphone);

DEFINE Statement


Creates a template inside a table template.
Main discussion: DEFINE COLUMN Statement, DEFINE FOOTER Statement, and DEFINE HEADER Statement

DEFINE template-type template-name</ option(s)>;
statements-and-attributes;
END;


Required Arguments

template-type

specifies the type of template to create, where template-type is one of the following:

COLUMN HEADER
FOOTER

The template-type determines what other statements and what attributes can go in the template. For details, see the documentation for the corresponding DEFINE statement.

template-name

specifies the name of the new object.

Restriction: template-name must be a single-level name.

Note:   To reference the template that you are creating from another template, create it outside the table template.  [cautionend]


Options

NOLIST

preserves the template-type when inheriting it from another table template.

Tip: If you specify an existing template-name without using the NOLIST option, then the template is overwritten.

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.


HEADER Statement


Declares a symbol as a header in the table and specifies the order of the headers.
HEADER header-specification(s);


Required Arguments

header-specification

is one or more headers. If the header is defined outside the current table template, reference it by its path in the template store. Headers in the template are laid out from top to bottom in the same order that they are specified in the HEADER statement. Each header-specification is one of the following:

"string"

specifies the text to use for the header. If you specify a string, you do not need to use a DEFINE HEADER statement. However, you cannot specify any header attributes except for a split character. If the SPLIT= header attribute is not in effect and if the first character of the header that you specify is neither a blank character nor an alphanumeric character, PROC TEMPLATE treats it as the split character.

See also: SPLIT=
header-path

is the path of the header template to use. 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.)

_LABEL_

uses the label of the output object as the header. Each SAS procedure specifies a label for each output object that it creates. The DATA step uses the value of the OBJECTLABEL= option as the label of the output object. If OBJECTLABEL= is not specified, it uses the text of the first TITLE statement as the label.

Default: If you omit a HEADER statement, then ODS makes a header for each header template (DEFINE HEADER statement), and places the headers in the same order that the header templates have in the table template.
Featured in: Creating a New Table Template

FOOTER Statement


Declares a symbol as a footer in the table and specifies the order of the footers.
FOOTER footer-specification(s);


Required Arguments

footer-specification

is one or more footers. If the footer is defined outside the current table template, reference it by its path in the template store. Footers in the template are laid out from top to bottom in the same order that they are specified in the FOOTER statement. Each footer-specification is one of the following:

"string"

specifies the text to use for the footer. If you specify a string, you do not need to specify a DEFINE FOOTER statement. However, you cannot specify any footer attributes except for a split character. If the SPLIT= attribute is not in effect and if the first character of the footer that you specify is neither a blank character nor an alphanumeric character, PROC TEMPLATE treats it as the split character.

See also: SPLIT=
footer-path

is the path of the footer template to use. A footer-path consists of one or more names, separated by periods. Each name represents a directory in a template store, which is s a type of SAS file.

_LABEL_

uses the label of the output object as the footer. Each SAS procedure specifies a label for each output object that it creates. The DATA step uses the value of the OBJECTLABEL= option as the label of the output object. If OBJECTLABEL= is not specified, it uses the text of the first TITLE statement as the label.

Default: If you omit a FOOTER statement, ODS makes a footer for each footer template (DEFINE FOOTER statement), and places the footers in the same order that the footer templates have in the table template.

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.


TRANSLATE INTO Statement


Translates the specified numeric values to other values.
Restriction: The TRANSLATE INTO statement in a table template applies only to numeric variables. To translate the values of a character variable, use TRANSLATE INTO in the template of that column. (See DEFINE COLUMN Statement).
Featured in: Setting the Style Element for Cells Based on Their Values

TRANSLATE expression-1 INTO expression-2 <..., expression-n INTO expression-m>;


Required Arguments

expression-1

is an expression that is evaluated for each table cell that contains a numeric variable.

If expression-1 resolves to TRUE (a non-zero value), the translation that is specified is used for the current cell. If expression-1 is FALSE (zero), the next expression in the statement is evaluated. Thus, you can string multiple expressions together to format cells conditionally.

expression has this form:

expression-1 <comparison-operator expression-n>

expression

is an arithmetic or logical expression that consists of a sequence of operators and operands. An operator is a symbol that requests a comparison, logical operation, or arithmetic calculation. An operand is one of the following:

constant

is a fixed value such as the name of a column or symbols that are declared in a DYNAMIC, MVAR, or NMVAR statement in the current template.

SAS function

specifies a SAS function. For information on SAS functions, see SAS Language Reference: Dictionary.

Built-in variable

is a special kind of WHERE expression operand that helps you find common values in table templates. Built-in variables are one or more of the following:

_COLUMN_

is a column number. Column numbering begins with 1.

Alias: _COL_
Featured in: Setting the Style Element for a Specific Column, Row, and Cell
_DATANAME_

is a data column name.

_DATATYPE_

is the data type of the column variable. The data type is either numeric ("num") or character ("char").

_LABEL_

is a column label.

Featured in: Setting the Style Element for a Specific Column, Row, and Cell
_ROW_

is a row number. Row numbering begins with 1.

Featured in: Setting the Style Element for a Specific Column, Row, and Cell
_STYLE_

is a style element name.

Featured in: Creating Master Templates
_VAL_

is the data value of a cell.

Tip: Use _VAL_ to represent the value of the current column.
Featured in: Creating Master Templates
comparison-operator

compares a variable with a value or with another variable. The following table lists the comparison operators:

Comparison Operators
Symbol Mnemonic Equivalent Definition
= EQ Equal to
^= or ~= or ¬= or <> NE Not equal to
> GT Greater than
< LT Less than
>= GE Greater than or equal to
<= LE Less than or equal to

IN Equal to one from a list of values

Restriction: You cannot reference the values of other columns in expression-1.
Tip: Using an expression of 1 as the last expression in the TRANSLATE-INTO statement specifies a translation for any cells that did not meet an earlier condition.
Featured in: Setting the Style Element for a Specific Column, Row, and Cell
See also: You can use any expression that can be used in the WHERE= data set option. For information on expressions that you can use in the WHERE data set option, see the WHERE data set option in SAS Language Reference: Dictionary and "WHERE Expression Processing" in SAS Language Reference: Concepts.
expression-2

is an expression that specifies the value to use in the cell in place of the variable's actual value.

expression has this form:

expression-1 <comparison-operator expression-n>

expression

is an arithmetic or logical expression that consists of a sequence of operators and operands. An operator is a symbol that requests a comparison, logical operation, or arithmetic calculation. An operand is one of the following:

constant

is a fixed value such as the name of a column or symbols that are declared in a DYNAMIC, MVAR, or NMVAR statement in the current template.

SAS function

specifies a SAS function. For information on SAS functions, see SAS Language Reference: Dictionary.

Built-in variable

a special kind of WHERE expression operand that helps you find common values in table templates. Built-in variables are one or more of the following:

_COLUMN_

is a column number. Column numbering begins with 1.

Alias: _COL_
Featured in: Setting the Style Element for a Specific Column, Row, and Cell
_DATANAME_

is a data column name.

_DATATYPE_

is the data type of the column variable. The data type is either numeric ("num") or character ("char").

_LABEL_

is a column label

Featured in: Setting the Style Element for a Specific Column, Row, and Cell
_ROW_

is a row number. Row numbering begins with 1.

Featured in: Setting the Style Element for a Specific Column, Row, and Cell
_STYLE_

is a style element name.

Featured in: Creating Master Templates
_VAL_

is the data value of a cell.

Tip: Use _VAL_ to represent the value of the current column.
Featured in: Creating Master Templates
comparison-operator

compares a variable with a value or with another variable. The following table lists the comparison operators:

Comparison Operators
Symbol Mnemonic Equivalent Definition
= EQ Equal to
^= or ~= or ¬= or <> NE Not equal to
> GT Greater than
< LT Less than
>= GE Greater than or equal to
<= LE Less than or equal to

IN Equal to one from a list of values

Restriction: expression-2 must resolve to a character value, not a numeric value.
Tip: When you translate a numeric value to a character value, the table template does not try to apply the numeric format that is associated with the column. Instead, it simply writes the character value into the formatted field, starting at the left. To right-justify the value, use the JUSTIFY=ON attribute.
Featured in: Setting the Style Element for a Specific Column, Row, and Cell
See also: JUSTIFY=
See also: You can use any expression that can be used in the WHERE= data set option. For information on expressions that you can use in the WHERE data set option, see the WHERE data set option in SAS Language Reference: Dictionary and "WHERE Expression Processing" in SAS Language Reference: Concepts.

END Statement


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

Previous Page | Next Page | Top of Page