Previous Page | Next Page

TEMPLATE Procedure: Creating Tabular Output

DEFINE COLUMN Statement


Creates a template for a column.
Requirement: An END statement must be the last statement in the template.
Interaction: A column template can include one or more header templates.
See also: DEFINE HEADER Statement
Featured in: Creating a New Table Template and Setting the Style Element for Cells Based on Their Values

DEFINE COLUMN column-path | Base.Template.Column
< / STORE=libref.template-store>;
<column-attribute-1; <... column-attribute-n; >>
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] ><..., expression-n AS <style-element-name><[style-attribute-specification(s)]>>;
COMPUTE AS expression;
DEFINE HEADER | Base.Template.Header template-path;
statements-and-attributes
END;
DYNAMIC variable-1<"text-1"> <... variable-n<"text-n">>;
MVAR variable-1<"text-1"> <... variable-n<"text-n">>;
NMVAR variable-1<"text-1"> <... variable-n<"text-n">>;
NOTES "text";
TRANSLATE expression-1 INTO expression-2 <..., expression-n INTO expression-m>;
END;

DEFINE COLUMN Statements
Task Statement
Set one or more column attributes column-attribute(s)
Set the style element of the cells in the column according to the values of the variables CELLSTYLE AS
Compute values for a column that is not in the data component, or modify the values of a column that is in the data component COMPUTE AS
Create a template for a column header DEFINE HEADER
Define a symbol that references a value that the data component supplies from the procedure or DATA step DYNAMIC
Define a symbol that references a macro variable. ODS will use the variable as a string. References to the macro variable are resolved when ODS binds the template and the data component to produce an output object. MVAR
Define a symbol that references a macro variable. ODS will convert the variable's value to a number (stored as a double) before using it. References to the macro variable are resolved when ODS binds the template and the data component to produce an output object. NMVAR
Provide information about the column NOTES
Translate the specified values to other values TRANSLATE INTO
End the template END


Required Arguments

column-path

specifies where to store the column template. A column-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.

Restriction: If the template is nested inside another template, template-path must be a single-level name because the nested template is stored in the same location as the original template.
Restriction: To reference the template that you are creating from another template, do not nest the template inside another one. For example, to reference a column template from multiple tables, do not define the column inside a table template.
Base.Template.Column

creates a master column template that is globally applied to all of your tabular output. After you create this template, you do not need to specify it explicitly in your SAS programs. It is automatically applied to all tabular output until you specifically remove the template from the item store.

Interaction: The Base.Template.Column master template attributes are overridden by other table templates.
Featured in: Creating Master Templates

Options

STORE=libref.template-store

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

Restriction: If the template is nested inside another template, do not use the STORE= option for the nested template because it is stored in the same location as the original template.
Restriction: The STORE= option does not become part of the template.

Column Attributes

This section lists all of the attributes that you can use in a column template. For all of the 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 column template with the DYNAMIC, MVAR, or NMVAR statement. If the attribute is 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_

Column Attributes
Task Attribute Destinations
Influence the appearance of the cells contents

Specify whether to suppress the value of a variable from one row to the next, if the value does not change based on the formatted value of the variable BLANK_DUPS All except OUTPUT
Specify whether to suppress the value of a variable from one row to the next if the value does not change based on the raw value of the variable BLANK_INTERNAL_DUPS All except OUTPUT
Select the best format for a column of a table CHOOSE_FORMAT= All
Specify whether to wrap the text in the current column FLOW LISTING
Specify the format for the column FORMAT= All
Specify the number of decimals for the column if it is not specified with FORMAT= column attribute FORMAT_NDEC= All
Specify the format width for the column if it is not specified with FORMAT= column attribute FORMAT_WIDTH= All
Supply a numeric value against which values in the column are compared to eliminate trivial values from printing FUZZ= All except OUTPUT
Specify the horizontal justification of the format field within the column (and for the column header if the template for the header does not include JUST=) JUST= All except OUTPUT
Specify whether to justify the format field within the column, or to justify the value within the column, without regard to the format field JUSTIFY All destinations except LISTING behave as if JUSTIFY=ON
When the text in the column uses more than one line, specify whether to try to divide the text equally among all lines or to maximize the amount of text in each line MAXIMIZE LISTING
Specify whether to draw a continuous line in the current column above the first table footer or below the last row of the column if there is no table footer OVERLINE LISTING
Specify whether to treat the text as preformatted text PREFORMATTED Markup family, printer family, and RTF
Specify whether to print the column PRINT All except OUTPUT
Specify a separator character to append to each value in the column SEPARATOR= LISTING
Specify the style element and style attributes to use for the column STYLE= Markup family, printer family, and RTF
Specify that the text graphic columns be turned off when a procedure is going to output a graph TEXT_GRAPHIC= All except OUTPUT and DOCUMENT
Specify the split character for the data in the column TEXT_SPLIT= All except OUTPUT
Specify whether to draw a continuous line in the current column below the column header, or above the first row of the column if there is no column header UNDERLINE= LISTING
Specify the vertical justification for the column VJUST= Markup family, printer family, and RTF
Specify the width of the column in characters WIDTH= LISTING
Specify the maximum width for this column WIDTH_MAX= LISTING
Customize column headers

Specify the text for the column header or the name of the header template HEADER= All
Specify whether to print the column header PRINT_HEADERS All except OUTPUT
Influence the relationship to other columns

Specify whether the column template is generic; that is, whether more than one variable use the template GENERIC= All except OUTPUT
Specify whether the column is an ID column ID LISTING and printer family
Specify whether to merge the current column with the column immediately to its right MERGE All except OUTPUT
Specify whether to merge the current column with the column immediately to its left PRE_MERGE All except OUTPUT
Specify the number of blank characters to leave between the current column and the column immediately to its left PRE_SPACE= LISTING
Specify the number of blank characters to leave between the current column and the column immediately to its right SPACE= LISTING
Influence the presentation of data panels

Influence the place at which ODS splits a table when it creates multiple data panels GLUE= LISTING, printer family, and RTF
Specify whether to delete the current column from the output object if doing so enables all the remaining columns to fit in the space that is provided without splitting the table into multiple data panels OPTIONAL LISTING
Other column attributes

Specify which format to use if both a column template and a data component specify a format DATA_FORMAT_OVERRIDE All
Specify the name of the column in the data component to associate with the current column DATANAME= All
Specify which special characters in headers for generic columns are to be used as split characters DEF_SPLIT All
Specify whether to include the column in an output data set DROP OUTPUT
Specify a label for the column LABEL= OUTPUT
Specify the column template that the current template inherits from PARENT= All
Specify the name to use for the corresponding variable in an output data set VARNAME= OUTPUT

BLANK_DUPS<=ON | OFF | variable>

specifies whether to suppress the value of a variable from one row to the next if the value does not change according to the formatted value of the variable.

Default: OFF
Interaction: If the CLASSLEVELS= table attribute is in effect, ODS ignores BLANK_DUPS=ON when any value changes in a preceding column that is also marked with BLANK_DUPS=ON.
Tip: The BLANK_DUPS attribute is valid in all destinations except the OUTPUT destination.

Note:   When the PRINTER destination suppresses the value of a variable, it also suppresses the horizontal rule above the blank cell.  [cautionend]

Featured in: Setting the Style Element for Cells Based on Their Values
BLANK_INTERNAL_DUPS<=ON | OFF | variable>

specifies whether to suppress the value of a variable from one row to the next if the value does not change according to the raw value of the variable.

Default: OFF
Interaction: If the CLASSLEVELS= table attribute is in effect, ODS ignores BLANK_INTERNAL_DUPS=ON when any value changes in a preceding column that is also marked with BLANK_INTERNAL_DUPS=ON.
Tip: The BLANK_INTERNAL_DUPS attribute is valid in all destinations except the OUTPUT destination.

Note:   When the PRINTER destination suppresses the value of a variable, it also suppresses the horizontal rule above the blank cell.  [cautionend]

CHOOSE_FORMAT= COMPROMISE | MAX | MAX_ABS | MIN_MAX

selects a format based on the actual values in the column of the table.

Default: If you omit the CHOOSE_FORMAT column attribute, then the default format is determined by either the data component or other attributes.
Restriction: CHOOSE_FORMAT is not supported for computed columns because those columns' values are computed outside of the data object.
Tip: If you specify a small value for the FORMAT_WIDTH= option, then CHOOSE_FORMAT might create a dw.3 format.
Tip: The CHOOSE_FORMAT= attribute is valid in all destinations.
See: Formatting Values in Table Columns for more information about column formats
COMPROMISE

looks at all of the values in the column and selects a good compromise format that works well for most values, but extreme values might shift to BEST format.

Tip: FORMAT_NDEC=d specifies the precision in digits.
Tip: The FORMAT_WIDTH= option suggests a maximum width. The actual format width might be smaller or it might be larger.
MAX

selects a format based on the maximum value in the column. Values are all expected to be positive so no space is reserved for a minus sign.

Default: By default, FORMAT_WIDTH=10 and FORMAT_NDEC= is ignored.
MAX_ABS

selects a format based on the maximum absolute value in the column. The format reserves space for a minus sign whether it is needed or not.

MIN_MAX

selects a format based on the minimum and maximum value in the column. The format reserves space for a minus sign only where it is actually needed.

Interaction: If FORMAT_NDEC=d is specified, a maximum of d decimal places is used.
DATA_FORMAT_OVERRIDE<=ON | OFF | variable>

specifies which format to use if both a column template and a data component specify a format.

Default: OFF
Tip: The DATA_FORMAT_OVERRIDE attribute is valid in all destinations.
ON

uses the format in the data component.

OFF

uses the format in the column template.

variable

uses the format of the specified variable.

DATANAME=column-name

specifies the name of the column in the data component to associate with the current column.

Default: By default, ODS associates the current column with a column of the same name in the data component.
Tip: The DATANAME= attribute is valid in all destinations.
DEF_SPLIT

specifies which special characters in headers for generic columns are to be used as split characters.

Tip: The DEF_SPLIT destination is valid in all destinations.
DROP<=ON | OFF | variable>

specifies whether to include the column in an output data set.

Default: OFF
Tip: The DROP attribute is valid only in the OUTPUT destination.
FLOW<=ON | OFF | variable>

specifies whether to wrap the text in the current column if it is too long to fit in the space that is provided.

Default: ON if the format width of the column is greater than the column width. OFF if the format width of the column is not greater than the column width.
See also: MAXIMIZE=
Tip: The FLOW attribute is valid only in the LISTING destination.

Note:   The HTML and PRINTER destinations always wrap the text if it is too long to fit in the space that is provided.  [cautionend]

FORMAT=format-name <format-width <decimal-width>> | variable

specifies the format for the column.

Default: If you omit the FORMAT= option, then the format that the data component provides is used. If the data component does not provide a format, ODS uses one of the following:
  • BEST8. for integers

  • D12.3 for doubles

  • the length of the variable for character variables

Restriction: If you specify a format width for a numeric column, then its value cannot exceed 32.
Tip: The FORMAT= attribute is valid in all destinations.
FORMAT_NDEC= number | variable

specifies the number of decimals for the column.

Default: The decimal width that is specified with the FORMAT= column attribute
Range: Number is a whole number from 0 to 32
Interaction: If you specify a decimal width using both the FORMAT= and the FORMAT_NDEC= attributes, then ODS uses the width that you specify with the FORMAT= attribute.
Tip: The FORMAT_NDEC= attribute is valid in all attributes.
FORMAT_WIDTH=positive-integer | variable

specifies the format width for the column.

Default: If you omit the column attribute FORMAT_WIDTH=, then ODS uses the format specified in the FORMAT= attribute.
Range: 1 to 32 for numeric variables; operating system limit for character variables
Interaction: If you specify a format width using both the FORMAT= and the FORMAT_WIDTH= attributes, then the width that you specify with the FORMAT= attribute is used.
Tip: The FORMAT_WIDTH= attribute is valid in all destinations.
FUZZ=number | variable

supplies a numeric value against which to compare values in the column to eliminate trivial values from printing. A number whose absolute value is less than or equal to the FUZZ= value is printed as 0. However, the real value of the number is used in any computations based on that number.

Default: This is the smallest representable floating-point number on the computer that you are using.
Tip: The FUZZ= attribute is valid in all destinations except the OUTPUT destination.
GENERIC<=ON | OFF | variable>

specifies whether the column template can be used by more than one column. Generic columns are useful in tables with many similar columns. For example, the table templates for both PROC SQL and the DATA step define only two columns: one for character variables and one for numeric variables. When a program runs, it determines which column template the data component should use for each column.

Default: OFF
Tip: The GENERIC attribute is valid in all destinations except the OUTPUT destination.
Featured in: Creating a New Table Template and Setting the Style Element for Cells Based on Their Values
GLUE=integer | variable

Influences the places at which ODS splits a table when it creates multiple data panels. ODS creates multiple data panels from a table that is too wide to fit in the allotted space. The higher the value of GLUE= is, the less likely it is that ODS will split the table between the current column and the column to its right.

Default: 1
Range: -1 to 327
Tip: A value of -1 forces the table to split between the current column and the column to its right.
Tip: The GLUE= attribute is valid only in the LISTING, printer family, and RTF destinations.
HEADER=header-specification

specifies the text for the column header or the name of the header template. header-specification is one of the following:

"text"

specifies the actual text of the header.

Requirement: text must be enclosed by quotation marks.
header-name

specifies the name of a header template to use. Create a header template with the DEFINE HEADER statement (see DEFINE HEADER Statement). If header-name is a single-level name, the header template must occur within the current column template.

variable

specifies the name of a variable declared with the DYNAMIC, MVAR, or NMVAR statement. The value of the variable becomes the column header.

_LABEL_

Uses the label that is specified in the data component for the column header.

Default: _LABEL_
Interaction: If you are using the OUTPUT destination, then the HEADER= attribute does not change the label of the variable in the data set. To change the label in the data set, use the LABEL= attribute.
Tip: The HEADER= option provides a simple way to specify the text of a column header. To customize the header further, use the DEFINE HEADER statement with the appropriate header attributes. (See DEFINE HEADER Statement.)
Tip: Use the split character in the text of the header to force the text to a new line.
See also: LABEL= and TEXT_SPLIT=
Tip: The HEADER= attribute is valid in all destinations.
Featured in: Creating a New Table Template and Creating a Stand-Alone Style
ID<=ON | OFF | variable>

specifies whether the column is an ID column. An ID column is repeated on each data panel. (ODS creates multiple data panels when a table is too wide to fit in the allotted space.)

Default: OFF
Tip: ODS treats all columns up to and including a column that is marked with ID=ON as ID columns.
Tip: The ID attribute is valid only in LISTING and printer family destinations.
Featured in: Creating a New Table Template
JUST=justification | variable

specifies the horizontal justification of the format field within the column (and of the header if the template for the header does not include JUST=).

justification is one of the following:

CENTER

specifies center justification.

Alias: C
Interaction: To use center justification in printer family and RTF destinations, also specify JUSTIFY=ON.
DEC

specifies aligning the values by the decimal point.

Alias: D
Restriction: Decimal alignment is supported for printer family and RTF destinations only.
LEFT

specifies left justification.

Alias: L
RIGHT

specifies right justification.

Alias: R
Default: LEFT for columns that contain character values; RIGHT for columns that contain numeric values.
Interaction: The TEXTALIGN= style attribute overrides the value of JUST=.
Interaction: For the LISTING destination, ODS justifies the format field within the column width. At times, you can specify the JUSTIFY= attribute to get the results that you want. See the discussion of the JUSTIFY attribute.
Tip: The JUST= attribute is valid in all destinations except the OUTPUT destination.
Main discussion: Values in Table Columns and How They Are Justified
See also: FORMAT= and WIDTH=
Featured in: Editing a Table Template That a SAS Procedure Uses
JUSTIFY<=ON | OFF | variable>

specifies whether to justify the format field within the column or to justify the value within the column without regard to the format field.

Default: OFF
Interaction: JUSTIFY=ON can interfere with decimal alignment in the LISTING destination.
Tip: If you translate numeric data to character data, you might need to use JUSTIFY= to align the data.
Tip: All destinations except the LISTING destinations justify values as if JUSTIFY=ON.
Main discussion: Values in Table Columns and How They Are Justified
Featured in: Setting the Style Element for Cells Based on Their Values
LABEL="text" | variable

specifies a label for the column in the output data set.

Default: If you omit a label, ODS uses the label that is specified in the data component. If no label is specified in the data component, ODS uses the header for the column as the label.
Tip: The LABEL= attribute is valid only in the OUTPUT destination.
Tip: If the OUTPUT destination is open, then the LABEL= attribute provides a label for the corresponding variable in the output data set. This label overrides any label that is specified in the data component.
MAXIMIZE<=ON | OFF | variable>

specifies whether to try to divide the text equally among all lines or to maximize the amount of text in each line when the text in the column uses more than one line. For example, if the text spans three lines, MAXIMIZE=ON can result in 45% of the text on the first line, 45% of the text on the second line, and 10% of the text on the third line. MAXIMIZE=OFF can result in 33% of the text on each line. MAXIMIZE=ON can write lines of text that vary greatly in length. MAXIMIZE=OFF can result in using less than the full column width.

Default: OFF
Interaction: This attribute is effective only if the column is defined with FLOW=ON (see the discussion of the FLOW= attribute).
Tip: The MAXIMIZE= attribute is valid only in the LISTING destination.
MERGE<=ON | OFF | variable>

specifies whether to merge the current column with the column immediately to its right. When you set MERGE=ON for the current column, the data in each row of the column is merged with the data in the same row of the next column. ODS applies the format, justification, spacing, and prespacing attributes to each column independently. Then, it concatenates the columns. Finally, it applies to the concatenated data all the remaining attributes that are specified on the column that does not have MERGE= set.

Default: OFF
Restriction: You cannot use both MERGE=ON and PRE_MERGE=ON in the same column template. You cannot merge or premerge a column with another column that has either MERGE=ON or PRE_MERGE=ON. Note that you can merge three columns by setting MERGE=ON for the first column, no merge or premerge attributes for the second column, and PRE_MERGE=ON for the third column.
Tip: The MERGE= attribute is valid in all destinations except the OUTPUT destination.
See also: The PRE_MERGE= attribute
OPTIONAL<=ON | OFF | variable>

specifies whether to delete the current column from the output object if doing so enables all the remaining columns to fit in the space that is provided without splitting the table into multiple data panels.

Default: OFF
Interaction: If multiple column templates contain OPTIONAL=ON, either all or none of these columns are included in the output object.
Tip: The OPTIONAL attribute is valid only in the LISTING destination.
OVERLINE<=ON | OFF | variable>

specifies whether to draw a continuous line in the current column above the first table footer (or, if there is no table footer, below the last row of the column). The second formatting character is used to draw the line.

Default: OFF
Tip: The OVERLINE= attribute is valid only in the LISTING destination.
See also: For information on formatting characters see the discussion of the FORMCHAR= attribute.
PARENT=variable

specifies the column template from which the current template inherits attributes and statements. A column-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. The current template inherits from the specified column in the first readable template store in the current path.

When you specify a parent, all of the attributes and statements that are specified in the parent's template are used in the current template unless the current template specifically overrides them.

Tip: The PARENT= attribute is valid in all destinations.
PREFORMATTED<=ON | OFF | variable>

specifies whether to treat the text as preformatted text. When text is preformatted, ODS honors line breaks as well as leading, trailing, and internal spaces. It also displays the text in a monospace font.

Default: OFF
Interaction: When PREFORMATTED=ON, ODS uses the DataFixed style element unless you specify another style element with the STYLE= column attribute.
Tip: The PREFORMATTED attribute is valid in the markup family, printer family, and RTF destinations.
PRE_MERGE<=ON | OFF | variable>

specifies whether to merge the current column with the column immediately to its left. When you set PRE_MERGE=ON for the current column, the data in each row of the column is merged with the data in the same row of the previous column. ODS applies the format, justification, spacing, and prespacing attributes to each column independently. Then, it concatenates the columns. Finally, it applies to the concatenated data all the remaining attributes that are specified on the column that does not have PRE_MERGE= set.

Default: OFF
Restriction: You cannot use both MERGE=ON and PRE_MERGE=ON in the same column template. You cannot merge or premerge a column with another column that has either MERGE=ON or PRE_MERGE=ON. Note that you can merge three columns by setting MERGE=ON for the first column, no merge or premerge attributes for the second column, and PRE_MERGE=ON for the third column.
Tip: The PRE_IMAGE attribute is valid in all destinations except the OUTPUT destination.
See also: MERGE=
PRE_SPACE=non-negative-integer

specifies the number of blank characters to leave between the current column and the column immediately to its left.

Default: A value in the range that is bounded by the COL_SPACE_MIN and COL_SPACE_MAX table attributes.
Interaction: If PRE_SPACE= and SPACE= are specified for the same intercolumn space, ODS honors PRE_SPACE=.
See also: The SPACE= column attribute, the COL_SPACE_MIN= table attribute, and the COL_SPACE_MAX= table attribute
Tip: The PRE_SPACE= attribute is valid only in the LISTING destination.
PRINT<=ON | OFF | variable>

specifies whether to print the column.

Default: ON
Interaction: If you specify the column attribute PRINT=OFF, then you turn off the value of a column if it 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: If all columns in a stacked column have PRINT=OFF specified, then the entire column is removed from the table.
Tip: The PRINT attribute is valid in all destination except the OUTPUT destination.
See also: The OPTIONAL= column attribute and DROP= column attribute
PRINT_HEADERS<=ON | OFF | variable>

specifies whether to print the column header and any underlining and overlining.

Default: ON
See also: UNDERLINE= and OVERLINE=
Tip: The PRINT_HEADERS attribute is valid in all destination except the OUTPUT destination.
SEPARATOR="character" | variable

specifies a separator character to append to each value in the column.

Default: None
Restriction: The SEPARATOR= column attribute is valid only for character variables.
Tip: To specify a hexadecimal character as the separator character, put an x after the closing quote. For example, this option assigns the hexadecimal character 2D as the separator character:
separator="2D"x
Tip: The SEPARATOR= attribute is valid only in the LISTING destination.
SPACE=positive-integer | variable

specifies the number of blank characters to leave between the current column and the column immediately to its right.

Default: A value in the range that is bounded by the COL_SPACE_MIN and COL_SPACE_MAX table attributes.
Interaction: If PRE_SPACE= and SPACE= are specified for the same intercolumn space, ODS honors PRE_SPACE=.
See also: The PRE_SPACE= column attribute, the COL_SPACE_MIN= table attribute, and the COL_SPACE_MAX= table attribute
Tip: The SPACE= attribute is valid only in the LISTING destination.
STYLE=<style-element-name><[style-attribute-specification(s)]>

specifies the style element and any changes to its attributes to use for the current column. 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 display the data in the column. 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 TEMPLATE Procedure: Creating a Style Template (Definition)). By default, ODS displays different parts of ODS output with different style elements. For example, by default, the data cells in a column are displayed with the style element Data. You would be most likely to use the following style elements with the STYLE= column attribute:

  • Data

  • DataFixed

  • DataEmpty

  • DataEmphasis

  • DataeEphasisFixed

  • DataStrong

  • DataStrongFixed

The style element provides the basis for displaying the column. Additional style attributes that you provide can modify the display.

For information on viewing a style so that you can see the style elements that are available, see Viewing the Contents of a Style. For information about the default style that ODS uses, see Working with Styles.

style-element-name is either the name of a style element or a variable whose value is a style element.

Default: Data
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 and Their Values.

Tip: The STYLE= attribute is valid only in the markup family, printer family, and RTF destinations.
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.
Featured in: Creating a New Table Template
TEXT_GRAPHIC= ON | OFF

specifies that the text graphic columns be turned off or on when a procedure is going to output a graph.

Default: OFF
TEXT_SPLIT="character" | variable

specifies the split character for the data in the column. The value in the column is broken when it reaches that character and continues the value on the next line. The split character itself is not part of the data and does not appear in the column.

Default: None
Tip: The TEXT_SPLIT= attribute is valid in all destinations except the OUTPUT destination.
UNDERLINE<=ON | OFF | variable>

specifies whether to draw a continuous line in the current column below the column header (or, if there is no column header, above the first row of the column). The second formatting character is used to draw the line.

Default: OFF
Main discussion: See the discussion of the FORMCHAR= attribute
Tip: The UNDERLINE= attribute is valid only in the LISTING destination.
VARNAME=variable-name | variable

specifies the name to use for the corresponding variable in an output data set.

Default: If you omit VARNAME=, then the value of the DATANAME= attribute is used. If you omit DATANAME=, then the name of the column is used.
Tip: If you use VARNAME= to specify the same name for different columns, a number is appended to the name each time that the name is used.
Tip: The VARNAME= attribute is valid only in the OUTPUT destination.
VJUST=justification | variable

Specifies the vertical justification for the column. justification is one of the following:

TOP

places the first line of text as high as possible.

Alias: T
CENTER

centers the text vertically.

Alias: C
BOTTOM

places the last line of text as low as possible.

Alias: B
Default: TOP
Tip: The VJUST= attribute is valid only in the markup family, printer family, and RTF destinations.
Featured in: Creating a New Table Template
WIDTH=positive-integer | variable

specifies the width of the column in characters.

Default: If you omit a width, the format width is used. If the column has no format associated with it, ODS uses one of the following widths:
  • 8 for integers

  • 12 for doubles

  • data length for character variables

Interaction: The length of the column header can influence the width of the column.
See also: WIDTH_MAX= header attribute and WIDTH= header attribute
Tip: The WIDTH= attribute is valid only in the LISTING destination.
WIDTH_MAX=positive-integer | variable

specifies the maximum width allowed for this column. By default, PROC TEMPLATE extends the width of the column if the header is wider than the data. The width of the column can be anywhere between the values of WIDTH= and WIDTH_MAX=.

Default: The width of the format for the column
Tip: The WIDTH_MAX= attribute is valid only in the LISTING destination.

CELLSTYLE AS Statement


Sets the style element of the cells in the column 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 cell in the column. 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 column 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 column variables that are numeric have a red font color and column variables that are character 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 that is used for the column.

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

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

Options

Note:   Neither style-attribute-specification nor style-element-name is required. However, you must use at least one of them.  [cautionend]

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 column template, see Style Attributes and Their Values.
Default: If you do not specify any style attributes to modify, ODS uses the unmodified style-element-name.
style-element-name

is the name of the style element that displays the data in the column. The style element must be part of a style that is registered with the Output Delivery System. SAS provides some styles. Create customized styles by using PROC TEMPLATE (see DEFINE STYLE Statement). By default, ODS displays different parts of ODS output with different style elements. For example, by default, the data cells in a column are displayed with the style element Data. The style elements that you would be most likely to use with the CELLSTYLE AS statement in a column template are the following.

  • Data

  • DataFixed

  • DataEmpty

  • DataEmphasis

  • DataEmphasisFixed

  • DataStrong

  • DataStrongFixed

The style element provides the basis for displaying the column. Additional style attributes that you provide can modify the display.

Default: Data
See also: Viewing the Contents of a Style
See also: Working with Styles

COMPUTE AS Statement


Computes values for a column that is not in the data component, or modifies the values of a column that is in the data component.
COMPUTE AS expression;


Required Arguments

expression

is an expression that assigns a value to each table cell in the column.

expression has this form:

expression-1 <comparison-operator expression-n>

expression

is an arithmetic or logical sequence of operators and operands. An operator is a symbol that requests a comparison, a logical operation, or an 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.

To reference another column in a COMPUTE AS statement, use the name of the column. In addition, if the column has values in the data component, you can reference the column itself in the expression.

For example, this DEFINE COLUMN block defines a column that contains the square root of the value in the column called Source:

define column sqroot;
   compute as sqrt(source);
   header="Square Root";
   format=6.4;
end;
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 column 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.

_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 another variable.

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

Tip: The COMPUTE AS statement can alter values in an output object. None of the templates that SAS provides modifies any values. To determine if a template was provided by SAS, use the ODS VERIFY Statement. If the template is not from SAS, the ODS VERIFY statement returns a warning when it runs the SAS program that uses the template. If you receive such a warning, use the SOURCE statement to look at the template and determine if the COMPUTE AS statement alters values. (See SOURCE Statement.)
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.

DEFINE HEADER Statement


Creates a template for a header inside a column template.
Main discussion: DEFINE HEADER Statement

DEFINE HEADERBase.Template.Header | template-name
</ STORE=libref.template-store>;
statements-and-attributes
END;


Required Arguments

template-name

specifies the name of a new header.

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

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

Base.Template.Header

creates a master header template that is globally applied to all of your tabular output. Once this template is created, you do not need to explicitly specify it in your SAS programs. The template is applied automatically to all tabular output until you specifically remove the template from the item store.

Interaction: The Base.Template.Header master template attributes are overridden by other table templates.
Featured in: Creating Master Templates
statements-and-attributes

specifies the statements and header attributes that define a header inside a column.

See: DEFINE HEADER Statement

Options

STORE=libref.template-store

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

Restriction: If the template is nested inside another template, do not use the STORE= option for the nested template because it is stored where the original template is stored.
Restriction: The STORE= option does not become part of the template.
DYNAMIC Statement

DYNAMIC Statement


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

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

Required Arguments

variable

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

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

Options

text

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


MVAR Statement


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

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


Required Arguments

variable

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

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

Options

text

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


NMVAR Statement


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

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


Required Arguments

variable

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

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

Options

text

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


NOTES Statement


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

NOTES 'text';

Required Arguments

text

provides information about the table.


TRANSLATE INTO Statement


Translates the specified values to other 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 in the column. 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 column 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 another variable.

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

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 variables:

_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 column template 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. 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