Chapter Contents

Previous

Next
The TEMPLATE Procedure

DEFINE COLUMN Statement


Creates a definition for a column.

Requirement: An END statement must be the last statement in the definition.
Interaction: A column definition can include one or more header definitions.
See also: DEFINE HEADER Statement
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 COLUMN column-path< / STORE=libname.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 definition-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;

To do this ... Use this statement
Set one or more column attributes. column-attributes
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 definition 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 definition 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 definition 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 definition. END


Required Arguments

column-path
specifies where to store the column definition. A column-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 that you can write to in the current path.
Restriction: If the definition is nested inside another definition, definition-path must be a single-level name.
Restriction: If you want to reference the definition that you are creating from another definition, do not nest the definition inside another one. For example, if you want to reference a column definition from multiple tables, do not define the column inside a table definition.


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.
Restriction: If the definition is nested inside another definition, you cannot use the STORE= option.
Availability: Version 8 of the SAS System


Column Attributes

This section lists all the attributes that you can use in a column 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 column 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 appearance of the contents of the cells

Specify whether or not to suppress the value of a variable from one row to the next if the value does not change. BLANK_DUPS=

Specify whether or not to wrap the text in the current column if it is too long to fit in the space that is provided. FLOW=

Specify the format for the column. FORMAT=

Specify the format width for the column if it isn't specified with FORMAT=. FORMAT_WIDTH=

Specify the number of decimals for the column if it isn't specified with FORMAT=. FORMAT_NDEC=

Supply a numeric value against which values in the column are compared to eliminate trivial values (absolute values less than the FUZZ= value) from computation and printing. FUZZ=

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

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=

Specify whether to try to divide the text equally among all lines or to maximize the amount of text in each line when the text in the column uses more than one line. MAXIMIZE=

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

Specify whether or not to treat the text as preformatted text. PREFORMATTED=

Specify whether or not to print the column. PRINT=

Specify a separator character to append to each value in the column. SEPARATOR=

Specify the style element and style attributes to use for the column. STYLE=

Specify the split character for the data in the column. TEXT_SPLIT=

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

Specify the vertical justification for the column. VJUST=

Specify the width of the column in characters. WIDTH=

Specify the maximum width allowed for this column. WIDTH_MAX=
Customize column headers

Specify the text for the column header. HEADER=

Specify whether or not to print the column header. PRINT_HEADERS=
Influence the relationship to other columns

Specify whether or not the column definition is generic -- that is, whether or not it can be used by more than one variable. GENERIC=

Specify whether or not the column is an ID column. ID=

Specify whether or not to merge the current column with the column immediately to its right. MERGE=

Specify whether or not to merge the current column with the column immediately to its left. PRE_MERGE=

Specify the number of blank characters to leave between the current column and the column immediately to its left. PRE_SPACE=

Specify the number of blank characters to leave between the current column and the column immediately to its right. SPACE=
Influence the presentation of data panels

Influence the place at which ODS splits a table when it creates multiple data panels. GLUE=

Specify whether or not 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=
Specify the name of the column in the data component to associate with the current column. DATANAME=
Specify a label for the column. LABEL=
Specify the column definition that the current definition inherits from. PARENT=
Specify the name to use for the corresponding variable in an output data set. VARNAME=
Specify whether or not to include the column in an output data set. DROP=
Specify which format to use if both a column definition and a data component specify one. DATA_FORMAT_OVERRIDE=
*Different attributes affect different ODS destinations. For details, consult the documentation for a specific attribute.

BLANK_DUPS<=ON | OFF | variable>
specifies whether or not to suppress the value of a variable from one row to the next if the value does not change.
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.
ODS Destinations: All but Output. Note that when the Printer destination suppresses the value of a variable, it also suppresses the horizontal rule above the blank cell.
Featured in: Setting the Style Element for Cells Based on Their Values and Creating a Stand-alone Style Definition

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 in the data component.

OFF
Uses the format in the column definition.

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

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

DROP<=ON | OFF | variable>
specifies whether or not to include the column in an output data set.
Default: OFF
ODS Destinations: Output
Availability: Version 8 of the SAS System

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

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 don't specify FORMAT=, PROC TEMPLATE uses the format that the data component provides. If the data component does not provide a format, PROC TEMPLATE uses

  • best8. for integers

  • 12.3 for doubles

  • the length of the variable for character variables.

If the format is provided by the data component and if the format includes a format width or a decimal width, PROC TEMPLATE uses the specified format. However, if FORMAT_WIDTH=, FORMAT_NDEC=, or both are used in the column definition, PROC TEMPLATE uses those values instead of the ones that the data component provided with its format name.

Restriction: If you specify a format width for a numeric column, its value cannot exceed 32.
Interaction: If you specify a format name but do not specify a format width or a decimal width with the format name, PROC TEMPLATE uses the values that are specified by FORMAT_WIDTH= and FORMAT_NDEC=. If these options aren't specified, PROC TEMPLATE uses the values for format width and decimal width that the data component provides.
ODS Destinations: All

FORMAT_WIDTH=positive-integer | variable
specifies the format width for the column.
Default: the format width that is specified with FORMAT=
Range: 1 to 32 for numeric variables; operating system limit for character variables
Interaction: If you specify a format width with FORMAT= and with FORMAT_WIDTH=, PROC TEMPLATE uses the one that you specify with FORMAT_WIDTH=.
ODS Destinations: All

FORMAT_NDEC=positive-integer | variable
specifies the number of decimals for the column.
Default: the decimal width that is specified with FORMAT=
Interaction: If you specify a decimal width with FORMAT= and with FORMAT_NDEC=, PROC TEMPLATE uses the one that you specify with FORMAT_NDEC=.
ODS Destinations: All

FUZZ=number | variable
supplies a numeric value against which values in the column are compared to eliminate trivial values (absolute values less than the FUZZ= value) from computation and printing. A number whose absolute value is less than the FUZZ= value is treated as zero in computations and printing.
Default: the smallest representable floating-point number on the computer that you are using
ODS Destinations: All but Output

GENERIC<=ON | OFF | variable>
specifies whether or not the column definition is generic - that is, whether or not it can be used by more than one column. Generic columns are useful in tables with many similar columns. For instance, the table definitions for both PROC SQL and the DATA step define only two columns: one for character variables and one for numeric variables. When the program runs, it determines which column definition the data component should use for each column.
Default: OFF
ODS Destinations: All but Output
Featured in: Creating a New Table Definition, Setting the Style Element for Cells Based on Their Values, and Creating a Stand-alone Style Definition

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

HEADER=header-specification
specifies the text for the column header. header-specification can be one of the following:

'text'
Provides the actual text of the header.

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

variable
specifies the name of a variable that you declare 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_
Tip: The HEADER= option provides a simple way for you to specify the text of a column header. If you want to customize the header further, use the DEFINE HEADER statement with the appropriate header attributes. (See DEFINE HEADER Statement.)
Tip: You can use the split character in the text of the header to force the text to a new line.
See also: LABEL= and TEXT_SPLIT=
ODS Destinations: All

Note:   If you are using the Output destination, the column header becomes the label of the corresponding variable in the output data set if you do not specify one with the LABEL= attribute and if the data component does not supply one.  [cautionend]

Featured in: Creating a New Table Definition and Creating a Stand-alone Style Definition

ID<=ON | OFF | variable>
specifies whether or not 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.
ODS Destinations: Listing and Printer
Featured in: Creating a New Table Definition

JUST=justification | variable
specifies the horizontal justification of the format field within the column (and of the header if the definition for the header does not include JUST=). For a discussion of how the Listing destination justifies data, see How Are Values in Table Columns Justified?. justification can be one of the following:

Left
specifies left justification.
Alias: L

Right
specifies right justification.
Alias: R

Center
specifies center justification.
Alias: C

Default: LEFT for columns that contain character values; RIGHT for columns that contain numeric values.
Interaction: For the Listing destination, ODS justifies the format field within the column width. At times, you may need to specify the JUSTIFY= attribute to get the results that you want. See the discussion of JUSTIFY=.
See also: FORMAT= and WIDTH=
ODS Destinations: All but Output
Featured in: Customizing a Table Definition 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. For a discussion of how ODS destinations justify 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.
Featured in: Setting the Style Element for Cells Based on Their Values
ODS Destinations: Listing (The HTML and Printer destinations always behave as if JUSTIFY=ON.)

LABEL='text' | variable
specifies a label for the column in the output data set.
Default: If you do not specify 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.
ODS Destinations: Output
Tip: If the Output destination is open, LABEL= 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 might 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 would result in 33% of the text on each line. MAXIMIZE=ON may write lines of text that vary greatly in length. MAXIMIZE=OFF may 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 FLOW=).
ODS Destinations: Listing

MERGE<=ON | OFF | variable>
specifies whether or not 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 definition. 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.
See also: PRE_MERGE=
ODS Destinations: All but Output

OPTIONAL<=ON | OFF | variable>
specifies whether or not 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 definitions contain OPTIONAL=ON, PROC TEMPLATE includes either all or none of these columns in the output object.
ODS Destinations: Listing

OVERLINE<=ON | OFF | variable>
specifies whether or not 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). PROC TEMPLATE uses the second formatting character to draw the line. (See the discussion of FORMCHAR=.)
Default: OFF
ODS Destinations: Listing

PARENT=column-path
specifies the column definition that the current definition inherits from. A column-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 the specified column in the first template store that you can read from in the current path.

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

PREFORMATTED<=ON | OFF | variable>
specifies whether or not 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 renders 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.
ODS Destinations: HTML and Printer

PRE_MERGE<=ON | OFF | variable>
specifies whether or not 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 definition. 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.
See also: MERGE=
ODS Destinations: All but Output

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: SPACE=, COL_SPACE_MIN=, and COL_SPACE_MAX=
ODS Destinations: Listing

PRINT<=ON | OFF | variable>
specifies whether or not to print the column.
Default: ON
See also: OPTIONAL= and DROP=
ODS Destinations: All but Output

PRINT_HEADERS<=ON | OFF | variable>
specifies whether or not to print the column header and any underlining and overlining.
Default: ON
See also: UNDERLINE= and OVERLINE=
ODS Destinations: All but Output

SEPARATOR='character' | variable
specifies a separator character to append to each value in the column.
Default: None
Tip: To specify a hexadecimal character as the separator character, put an x after the closing quote. For instance, the following option assigns the hexadecimal character 2D as the separator character:
                         separator='2D'x
ODS Destinations: Listing and Printer

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: PRE_SPACE=, COL_SPACE_MIN=, and COL_SPACE_MAX=
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 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 render the data in the column. 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 style elements. For instance, by default, the data in a column is rendered with the style element data. The style elements that you would be most likely to use with the STYLE= column attribute are

  • data

  • datafixed

  • dataempty

  • dataemphasis

  • dataemphasisfixed

  • datastrong

  • datastrongfixed.

The style element provides the basis for rendering the column. 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: 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.

ODS Destinations: HTML and Printer
Featured in: Creating a New Table Definition and Creating a Stand-alone Style Definition

TEXT_SPLIT='character' | variable
specifies the split character for the data in the column. PROC TEMPLATE breaks a value in the column 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
ODS Destinations: All but Output

UNDERLINE<=ON | OFF | variable>
specifies whether or not 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). PROC TEMPLATE uses the second formatting character to draw the line. (See the discussion of FORMCHAR=.)
Default: OFF
ODS Destinations: Listing

VARNAME=variable-name | variable
specifies the name to use for the corresponding variable in an output data set.
Default: If you do not specify VARNAME=, PROC TEMPLATE uses the the value of the DATANAME= attribute. If you do not specify DATANAME=, PROC TEMPLATE uses the name of the column.
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.
ODS Destinations: Output

VJUST=justification | variable
Specifies the vertical justification for the column. justification can be 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 for the Printer destination; CENTER for the HTML destination
ODS Destinations: HTML and Printer
Featured in: Creating a New Table Definition

WIDTH=positive-integer | variable
specifies the width of the column in characters.
Default: If you do not specify a width, PROC TEMPLATE uses the format width. If the column has no format associated with it, PROC TEMPLATE uses a width of

  • 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 and WIDTH= header attribute
ODS Destinations: Listing

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

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, font face, flyover) 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. 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 NMVAR statement in the 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.


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 definition, see Style Attributes.
Default: If you don't specify any style attributes to modify, ODS uses the unmodified style-element-name.

style-element-name
is the name of the style element to use to render the data in the column. The style element must be 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. 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 style elements. For instance, by default, the data in a column is rendered with the style element data. The style elements that you would be most likely to use with the CELLSTYLE-AS statement in a column definition are

The style element provides the basis for rendering the column. 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?.
Default: data

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

To reference another column in a COMPUTE-AS statement, use the name of the column. You may also reference symbols that you declared in a DYNAMIC, MVAR, or NVAR statement in the current definition. In addition, if the column has values in the data component, you may reference the column itself in the expression. However, if you are creating a column that does not exist in the data component, you cannot reference the column in the expression because there is no underlying value to use.

For example, the following 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;
Tip: The COMPUTE AS statement can alter values in an output object. None of the definitions that SAS Institute provides modifies any values. If you want to determine if a definition was provided by SAS Institute, use the ODS VERIFY statement (see ODS VERIFY Statement). If the definition is not from SAS Institute, the ODS VERIFY statement returns a warning when it runs the SAS program that uses the definition. If you receive such a warning, you can use the SOURCE statement to look at the definition and determine if the COMPUTE AS statement is used to alter values. (See SOURCE Statement.)
Tip: Because you can use column names in expression, _VAL_ is not recognized as an alias for the current column.

DEFINE HEADER Statement


Creates a definition for a header inside a column definition.

Main discussion: DEFINE HEADER Statement


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


Required Arguments

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

Note:   If you want to reference the header definition that you are creating from another definition, you must create it outside the column 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.
Main discussion: DYNAMIC Statement


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

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.
Main discussion: MVAR Statement


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

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.
Main discussion: NMVAR Statement


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

NOTES Statement


Provides information about the column.

Tip: The NOTES statement becomes part of the compiled column definition, which you can view with the SOURCE statement, whereas SAS comments do not.


NOTES 'text';


Required Arguments

text
provides information about the column.

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

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

END;


Chapter Contents

Previous

Next

Top of Page

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