Chapter Contents |
Previous |
Next |
The TEMPLATE Procedure |
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>;
|
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 |
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 |
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=ONFor 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. |
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 |
Default: | OFF |
ODS Destinations: | All |
Availability: | Version 8 of the SAS System |
Default: | By default, ODS associates the current column with a column of the same name in the data component. |
ODS Destinations: | All |
Default: | OFF |
ODS Destinations: | Output |
Availability: | Version 8 of the SAS System |
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. |
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
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 |
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 |
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 |
Default: | the smallest representable floating-point number on the computer that you are using |
ODS Destinations: | All but Output |
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 |
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 |
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. |
Featured in: | Creating a New Table Definition and Creating a Stand-alone Style Definition |
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 |
Alias: | L |
Alias: | R |
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 |
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.) |
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. |
Default: | OFF |
Interaction: | This attribute is effective only if the column is defined with FLOW=ON (see the discussion of FLOW=). |
ODS Destinations: | Listing |
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 |
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 |
Default: | OFF |
ODS Destinations: | Listing |
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 |
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 |
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 |
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 |
Default: | ON |
See also: | OPTIONAL= and DROP= |
ODS Destinations: | All but Output |
Default: | ON |
See also: | UNDERLINE= and OVERLINE= |
ODS Destinations: | All but Output |
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 |
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 |
Note: You can use braces
({ and }) instead of square brackets ([ and ]).
data
. The style elements
that you would be most likely to use with the STYLE= column attribute
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?.
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-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 |
Default: | None |
ODS Destinations: | All but Output |
Default: | OFF |
ODS Destinations: | Listing |
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 |
Alias: | T |
Alias: | C |
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 |
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
|
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 |
Default: | the width of the format for the column |
ODS Destinations: | Listing |
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 |
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.
style-attribute-name=style-attribute-value |
Default: | If you don't specify any style attributes to modify, ODS uses the unmodified style-element-name. |
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 expression; |
Required Arguments |
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. |
Main discussion: | DEFINE HEADER Statement |
DEFINE HEADER
definition-name ;
|
Required Arguments |
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. |
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'>>; |
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'>>; |
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'>>; |
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 |
TRANSLATE expression-1 INTO expression-2 <...,expression-n INTO expression-m>; |
Required Arguments |
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. |
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; |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.