Chapter Contents

Previous

Next
The TEMPLATE Procedure

DEFINE TABLE Statement


Creates a table definition.

Requirement: An END statement must be the last statement in the definition.
Interaction: A table definition can contain one or more column, header, or footer definitions.
Featured in: Creating a New Table Definition, Setting the Style Element for Cells Based on Their Values, and Creating a Stand-alone Style Definition


DEFINE TABLE table-path </ STORE=libname.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 definition-type definition-path;
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;

To do this ... Use this 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 definition 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 definition 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 definition 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 definition, or end the editing of a definition. END


Required Arguments

table-path
specifies where to store the table definition. 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.) PROC TEMPLATE writes the definition to the first template store in the current path that you can write to.


Options

STORE=libname.template-store
specifies the template store in which to store the definition. If the template store does not exist, it is created.
Availability: Version 8 of the SAS System


Table Attributes

This section lists all the attributes that you can use in a table definition. For all attributes that support a value of ON, the following forms are equivalent:

ATTRIBUTE-NAME
ATTRIBUTE-NAME=ON
For all attributes that support a value of variable, variable can be any variable that you declare in the table definition with the DYNAMIC, MVAR, or NMVAR statement. If the attribute is a boolean, the value of variable should resolve to one of the following:

ON YES 0
_ON_ _YES_ FALSE
1 OFF NO
TRUE _OFF_ _NO_

To do this ...* Use this attribute
Influence the layout of the table

Specify whether or not 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=

Specify whether or not to center each data panel independently if the entire table does not fit in one data panel CENTER=

Specify whether or not to force a new page before printing the table NEWPAGE=

Specify the number of sets of columns to place on a page PANELS=

Specify the number of blank characters to place between sets of columns when PANELS= is in effect PANELSPACE=

Specify the number of lines that must be available on the page in order to print the body of the table REQUIRED_SPACE=

Specify the number of lines to place between the previous output object and the current one TOPSPACE=
Influence the layout of rows and columns

Specify the maximum number of blank characters to place between columns COL_SPACE_MAX=

Specify the minimum number of blank characters to place between columns COL_SPACE_MIN=

Specify the name of the column whose value provides formatting information about the space before each row of the definition CONTROL=

Specify whether or not to double space between the rows of the table DOUBLE_SPACE=

Specify whether or not extra space is evenly divided among all columns of the table EVEN=

Specify whether or not to split a long stacked column across page boundaries SPLIT_STACK=
Influence the display of the values in header cells and data cells

Specify whether or not to suppress the blanking of 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=

Specify which format to use if both a column definition and a data component specify one DATA_FORMAT_OVERRIDE=

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=

Specify whether or not to order the columns by their order in the data component ORDER_DATA=

Specify the source of the values for the format width and the decimal width if they are not specified USE_FORMAT_DEFAULTS=

Use the column name as the column header if neither the column definition nor the data component specifies a header USE_NAME=
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=

Specify the number of blank lines to place between the last row of headers and the first row of data HEADER_SPACE=

Specify whether or not to draw a continuous line above the first table footer (or, if there is no table footer, below the last row of the data on a page) OVERLINE=

Specify whether or not to print table footers and any overlining of the table footers PRINT_FOOTERS=

Specify whether or not to print table headers and any underlining of the table headers PRINT_HEADERS=

Specify whether or not to draw a continuous line under the last table header (or, if there is no table header, under the last row of the data on a page) UNDERLINE=
Influence the HTML output

Specify whether or not to place the object in a table of contents if you create one CONTENT=

Specify the label to use for the output object in the contents file, the Results window, and the trace record CONTENTS_LABEL=
Specify whether or not to print the current byline before the table BYLINE=
Define the characters to use as the line-drawing characters in the table FORMCHAR=
Specify a label for the table LABEL=
Specify the table that the current definition inherits from PARENT=
Specify the style element to use for the table and any changes to the attributes STYLE=
Specify the special data set type of a SAS data set TYPE=
*Different attributes affect different ODS destinations. For details, consult the documentation for a specific attribute.

BALANCE<=ON | OFF | variable>
specifies whether or not 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
ODS Destinations: Listing and Printer

BYLINE<=ON | OFF | variable>
specifies whether or not to print the current byline before the table.
Default: OFF
Restriction: This attributes 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.
ODS Destinations: All but Output

CENTER<=ON | OFF | variable>
specifies whether or not to center each data panel independently if the entire table does not fit in the space that is provided.
Default: ON
ODS Destinations: Listing and Printer

CLASSLEVELS<=ON | OFF | variable>
specifies whether or not to suppress the blanking of 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
ODS Destinations: All but Output
Featured in: Creating a Stand-alone Style Definition

COL_SPACE_MAX=positive-integer | variable
specifies the maximum number of blank characters to place between the columns.
Default: 4
ODS Destinations: Listing

COL_SPACE_MIN=positive-integer | variable
specifies the minimum number of blank characters to place between the columns.
Default: 2
ODS Destinations: Listing

CONTENTS<=ON | OFF | variable>
specifies whether or not to place the object in a table of contents if you create one.
Default: ON
ODS Destinations: HTML

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.
ODS Destinations: HTML

CONTROL=column-name | variable
specifies the name of the column whose values provide formatting information about the space before each row of the definition. The value of CONTROL= should be the name of a column of type character with a length equal to 1.

If the value in the control column is ... This occurs before the row is created ...
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
a 'b' or a 'B' ODS tries to insert a panel break if the entire table does not fit in the space that is provided

Default: none
ODS Destinations: Listing and Printer

DATA_FORMAT_OVERRIDE<=ON | OFF | variable>
specifies which format to use if both a column definition and a data component specify one.

ON
uses the format that the data component specifies.

OFF
use the format that the column definition specifies.

Default: OFF
Availability: Version 8 of the SAS System
ODS Destinations: All

DOUBLE_SPACE<=ON | OFF | variable>
specifies whether or not to double space between the rows of the table.
Default: OFF
ODS Destinations: Listing
Featured in: Customizing a Table Definition that a SAS Procedure Uses and Creating a New Table Definition

EVEN<=ON | OFF | variable>
specifies whether or not extra space is evenly divided among all columns of the table.
Default: OFF
ODS Destinations: 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 footers.
Default: 1
ODS Destinations: Listing

FORMCHAR='string' | variable
Defines the characters to use as the line-drawing characters in the table. Currently, PROC TEMPLATE 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, you must specify both the first and second formatting characters. For instance, the following 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: You can use any character in formatting-characters, including hexadecimal characters. If you use hexadecimal characters, you must put an x after the closing quote. For instance, the following 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
ODS Destinations: Listing

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 underlining is a header.
Default: 1
ODS Destinations: Listing

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. For a discussion of how the Listing destination justifies data, see How Are Values in Table Columns Justified?.
Default: OFF
Interaction: JUSTIFY=ON can interfere with decimal alignment.
Tip: If you translate numeric data to character data, you may need to use JUSTIFY= to align the data as you wish.
ODS Destinations: Listing

LABEL='text' | variable
specifies a label for the table.
Default: PROC TEMPLATE uses the first of the following that it finds:

  • a label that the table definition provides.

  • a label that the data component provides.

  • the first spanning header in the table.

ODS Destinations: All

NEWPAGE<=ON | OFF | variable>
specifies whether or not 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.
ODS Destinations: All but Output

ORDER_DATA<=ON | OFF | variable>
specifies whether or not 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 do not use a COLUMN statement, the default order for columns is the order in which you define them in the definition.

Tip: The Output destination always uses the order of the columns in the data component when it creates an output data set.
Interaction: ORDER_DATA is most useful for ordering generic columns.
ODS Destinations: All but Output

OVERLINE<=ON | OFF | variable>
specifies whether or not 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). PROC TEMPLATE uses the second formatting character to draw the line. (See the discussion of FORMCHAR=.)
Default: OFF
See also: UNDERLINE= (for tables), UNDERLINE= (for columns), and OVERLINE= (for columns)
ODS Destinations: Listing
Featured in: Customizing a Table Definition 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 line size, you can 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 definition creates as many panels as it can. Let the table definition put your data in the maximum number of panels that can fit on the page by specifying a large number of panels (for example, 99).
ODS Destinations: Listing and Printer

PANEL_SPACE=positive-integer | variable
specifies the number of blank characters to place between sets of columns when PANELS= is in effect.
Default: 2
ODS Destinations: Listing

PARENT=table-path
specifies the table that the current definition 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 definition 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 the attributes and statements that are specified in the parent's definition are used in the current definition unless the current definition specifically overrides them.
ODS Destinations: All

PRINT_FOOTERS<=ON | OFF | variable>
specifies whether or not print table footers and any overlining of the table footers.
Default: ON
See also: OVERLINE=
ODS Destinations: All but Output

PRINT_HEADERS<=ON | OFF | variable>
specifies whether or not to print the table headers and any underlining of the table headers.
Default: ON
Interaction: When used in a table definition, PRINT_HEADERS affects only headers for the table, not the headers for individual columns. (See the discussion of the PRINT_HEADERS column attribute.)
See also: UNDERLINE=
ODS Destinations: All but Output

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
ODS Destinations: Listing and Printer

SPLIT_STACK<=ON | OFF | variable>
specifies whether or not to split a long stacked column across page boundaries.
Default: OFF
ODS Destinations: Listing

STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the table. Neither style-attribute-specification nor style-element-name is required. However, you must use at least one of them.

Note:   You can use braces ({ and }) instead of square brackets ([ and ]).   [cautionend]

style-element-name
is the name of the style element to use to render the table. The style element must be part of a style definition that is registered with the Output Delivery System. SAS Institute provides some style definitions. Users can create their own style definitions with PROC TEMPLATE (see DEFINE STYLE Statement). By default, ODS renders different parts of ODS output with different elements. For instance, by default, a table is rendered with the style element table. The style definitions that SAS Institute provides do not provide another style element that you would be likely to want to use instead of table. However, you may have a user-defined style element at your site that would be appropriate to specify.

The style element provides the basis for rendering the table. Additional style attributes that you provide can modify the rendering.

For information on finding an up-to-date list of the style definitions and for viewing a style definition so that you can see the style elements that are available, see Customizing Presentation Aspects of ODS Output. For information about the default style definition that ODS uses, see What Is the Default Style Definition Like?.

style-element-name can be either the name of a style element or a variable whose value is a style element.
Default: table

style-attribute-specification
describes the style attribute to change. Each style-attribute-specification has this general form:
style-attribute-name=style-attribute-value

For information on the style attributes that you can specify, see Style Attributes.

ODS Destinations: HTML and Printer

TOP_SPACE=positive-integer | variable
specifies the number of lines to place between the previous output object and the current one.
Default: 1
ODS Destinations: Listing and Printer

TYPE=string | variable
specifies the special data set type of a SAS data set.
Restriction: PROC TEMPLATE does not verify that

  • the 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.
Destination: Output

UNDERLINE<=ON | OFF | variable>
specifies whether or not to draw a continuous line under the last table header (or, if there is no table header, above the first row of data on a page). PROC TEMPLATE uses the second formatting character to draw the line. (See the discussion of FORMCHAR=.)
Default: OFF
See also: OVERLINE= (for tables), UNDERLINE= (for columns), and OVERLINE= (for columns)
ODS Destinations: Listing
Featured in: Customizing a Table Definition that a SAS Procedure Uses and Creating a New Table Definition

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
ODS Destinations: All but Output

USE_NAME<=ON | OFF | variable>
uses the column name as the column header if neither the column definition 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.
ODS Destinations: All but Output

WRAP<=ON | OFF | variable>
specifies whether to split a table that is too wide to fit in the space that is provided 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=
ODS Destinations: Listing and Printer

WRAP_SPACE<=ON | OFF | variable>
specifies whether or not 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=
ODS Destinations: Listing and Printer

CELLSTYLE-AS Statement


Sets the style element of the cells in the table that contain numeric variables according to the values of the variables. Use this statement to set the presentation characteristics (such as foreground color, font face, flyover) of individual cells.

Restriction: The CELLSTYLE-AS statement in a table definition applies only to numeric variables. To specify style elements for individual values of a character variable, use CELLSTYLE-AS in the definition of that column. (See DEFINE COLUMN Statement.)


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 numeric variable. It can be any numeric expression that is valid in the WHERE statement (or the WHERE= data set option). For information on expressions that you can use in the WHERE statement, see "Statements" in SAS Language Reference: Dictionary. Use _VAL_ to represent the value of the current column. You may also reference symbols that you declared in a DYNAMIC, MVAR, or NVAR statement in the table definition.

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.
Restriction: You may not reference the values of other columns in expression.
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.

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 definition, see Style Attributes.


Options

style-element-name
is the name of a style element that is part of a style definition that is registered with the Output Delivery System. SAS Institute provides some style definitions. You can create your own style definitions 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

The style element provides the basis for rendering the cell. Additional style attributes that you provide can modify the rendering.

COLUMN Statement


Declares a symbol as a column in the table and specifies the order of the columns.

Featured in: Creating a New Table Definition


COLUMN column(s);


Required Arguments

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

To stack values for two or more variables in the same column, put parentheses around the variables that you want to stack. 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 instance, the following COLUMN statement produces a definition in which

You can 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 instance, the following COLUMN statement produces a report in which

Default: If you do not use a COLUMN statement, ODS makes a column for each column definition (DEFINE COLUMN statement), and places the columns in the same order that the column definitions have in the table definition.

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

Tip: You can use a list of variable names, such as DAY1-DAY10, to specify multiple variables.

DEFINE Statement


Creates a definition inside a table definition.

Main discussion: DEFINE COLUMN Statement, DEFINE FOOTER Statement, and DEFINE HEADER Statement


DEFINE definition-type definition-name;
statements-and-attributes
END;


Required Arguments

definition-type
specifies the type of definition to create, where definition-type is one of the following:
COLUMN HEADER
FOOTER

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

definition-name
specifies the name of the new object.
Restriction: definition-name must be a single-level name.

Note:   If you want to reference the definition that you are creating from another definition, you must create it outside the table definition.  [cautionend]

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 definition of a table, column, header, or footer. A dynamic variable that is defined in a definition is available to that definition and to all the definitions that it contains.
Featured in: Creating a Stand-alone Style Definition


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 definition 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 you can place in the definition to explain the dynamic variable's use. Text of this type becomes part of the compiled definition, which you can view with the SOURCE statement, whereas SAS comments do not.

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 definition, you must reference it by its path in the template store. Footers in the definition are laid out from top to bottom in the same order that you specify them in the FOOTER statement. Each footer-specification can be

"string"
specifies the text to use for the footer. If you use a string, you do not need to use a DEFINE FOOTER statement. However, you cannot specify any footer attributes except for a split character. If SPLIT= 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 definition to use. A footer-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 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 do not use a FOOTER statement, ODS makes a footer for each footer definition (DEFINE FOOTER statement), and places the footers in the same order that the footer definitions have in the table definition.

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 definition, you must reference it by its path in the template store. Headers in the definition are laid out from top to bottom in the same order that you specify them in the HEADER statement. Each header-specification can be

"string"
specifies the text to use for the header. If you use 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 SPLIT= 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 definition 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 do not use a HEADER statement, ODS makes a header for each header definition (DEFINE HEADER statement), and places the headers in the same order that the header definitions have in the table definition.
Featured in: Creating a New Table Definition

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 definition and the data component to produce an output object.

Scope: You can use the MVAR statement in the definition of a table, column, header, or footer. A macro variable that is defined in a definition is available to that definition and to all the definitions that it contains.
Featured in: Creating a New Table Definition and Creating a Stand-alone Style Definition


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


Required Arguments

variable
Names a macro variable to reference in the definition. 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 definition and the data component.
Tip: You must declare macro variables this way in a definition. For example, to use the automatic macro variable SYSDATE9 in a definition, declare it in an MVAR statement and reference it as SYSDATE9, without an ampersand, in your PROC TEMPLATE step. If you use the ampersand, the macro resolves when the definition is compiled instead of when ODS binds the definition to the data component.


Options

text
is text that you can place in the definition to explain the macro variable's use. Text of this type becomes part of the compiled definition, 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 definition and the data component to produce an output object.

Scope: You can use the NMVAR statement in the definition of a table, column, header, or footer. A macro variable that is defined in a definition is available to that definition and to all the definitions 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 definition. 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 definition and the data component.
Tip: You must declare macro variables this way in a definition. For instance, 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 resolves when the definition is compiled instead of when ODS binds the definition to the data component.


Options

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

NOTES Statement


Provides information about the table.

Tip: The NOTES statement becomes part of the compiled column definition, 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 definition applies only to numeric variables. To translate the values of a character variable, use TRANSLATE-INTO in the definition 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. It can be any numeric expression that is valid in the WHERE statement (or the WHERE= data set option). For information on expressions that you can use in the WHERE statement, see "Statements" in SAS Language Reference: Dictionary. Use _VAL_ to represent the value of the current column. You may also reference symbols that you declared in a DYNAMIC, MVAR, or NVAR statement in the table definition.

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.
Restriction: You may not 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.

expression-2
is an expression that specifies the value to use in the cell in place of the variable's actual value. It can be any expression that is valid in the WHERE statement (or the WHERE= data set option). For information on expressions that you can use in the WHERE statement, see "Statements" in SAS Language Reference: Dictionary. Use _VAL_ to represent the value of the current column. You may also reference symbols that you declared in a DYNAMIC, MVAR, or NVAR statement in the table definition.
Restriction: expression-2 must resolve to a character value, not a numeric value.
Restriction: You may not reference the values of other columns in expression-2.
Tip: When you translate a numeric value to a character value, the table definition does not try to apply the numeric format that is associated with the column. Instead, it simply writes the character value into the format field, starting at the left. If you want the value to be right justified, use the JUSTIFY=ON attribute.
See also: JUSTIFY=

END Statement


Ends the table definition.

END;


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.