Previous Page | Next Page

TEMPLATE Procedure: Creating Crosstabulation Table Templates

DEFINE HEADER Statement


Creates a template for a header.
Featured in: Creating a Customized Crosstabulation Table Template with No Legend

DEFINE HEADER symbol;
<attribute-1;><...attribute-n>;
DYNAMIC variable-1<'text-1'> <... variable-n<'text-n'>>;
NOTES 'text';
TEXT header-specification </ expression>;
END;

DEFINE HEADER Statements
Task Statement
Set one or more header attributes header-attributes
Define a symbol that references a value that the data component supplies from the procedure DYNAMIC
Provide information about the crosstabulation table NOTES
End a header template END
Specify the text of the header or the footer TEXT


Required Arguments

symbol

specifies a name to be referenced by the HEADER statement.


DEFINE HEADER and DEFINE FOOTER Attribute Statements

This section lists all the attributes that you can use in a header or footer template.

DEFINE HEADER and DEFINE FOOTER Attribute Statements
Task Attribute
Specify alignment for headers and footers that wrap CINDENT=
Specify the number of blank lines to place between the current header and the next header or between the current footer and the previous footer SPACE=
Specify the style element and any changes to its attributes to use for the header or footer STYLE=

CINDENT='character'

specifies alignment for headers or footers that wrap. If a header or footer is too wide to fit on a single line, insert the specified character at the column position at which the second and subsequent lines should start. The first use of the CINDENT character determines the column position. For example, the following TEXT statement makes wrapped lines start at the same column as the left parenthesis:

text _COL_NAME_ "(;" _COL_LABEL_ ")"; CINDENT=';'; 
SPACE=positive-integer

specifies the number of blank lines to place between the current header and the next header or between the current footer and the previous footer.

Default: 0 for headers and 1 for footers
Tip: The SPACE= attribute is valid only in the LISTING destination.
Featured in: Creating a Customized Crosstabulation Table Template with No Legend
STYLE=<[style-element-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 template that is registered with the Output Delivery System. SAS provides some styles. You can create customized styles with PROC TEMPLATE. For details, see DEFINE STYLE Statement. By default, ODS produces different parts of ODS output with different elements. For example, by default, a table header is displayed with the style element Header. The style elements that you would most likely use with the STYLE= attribute for a table header are as follows:

  • Header

  • HeaderFixed

  • HeaderEmpty

  • HeaderEmphasis

  • HeaderEmphasisFixed

  • HeaderStrong

  • HeaderStrongFixed

The style elements that you would most likely use with the STYLE= attribute for a footer are as follows:

  • Footer

  • FooterFixed

  • FooterEmpty

  • FooterEmphasis

  • FooterEmphasisFixed

  • FooterStrong

  • FooterStrongFixed

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

For information on viewing a style template and the available style elements, see Viewing the Contents of a Style. For information about the default style template 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.

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 Customized Crosstabulation Table Template with No Legend

DYNAMIC Statement


Defines a symbol that references a value that the data component supplies from the procedure or DATA step.
Tip: A dynamic variable that is defined in a template is available to that template and all the templates that it contains.

DYNAMIC dynamic-variable(s) ;

Required Arguments

dynamic- variable(s)

is a variable that is defined by SAS in the crosstabulation template. After a dynamic variable has been defined, you can use it in the TEXT statement within a footer or header template.

FMISSING

is the number of missing values in the table.

Requirement: The FMISSING dynamic variable must be specified by the DYNAMIC statement before you can use the dynamic variable in an expression.
NOTITLE

is set to 1 if the PROC FREQ's NOTITLE option was used, and it is set to 0 if the NOTITLE option was not used.

Requirement: The NOTITLE dynamic variable must be specified by the DYNAMIC statement before you can use the dynamic variable in an expression.
SAMPLESIZE

is set to 0 if the table is empty. Otherwise, it is set to 1.

Requirement: The SAMPLESIZE dynamic variable must be specified by the DYNAMIC statement before you can use the dynamic variable in an expression.
STRATNUM

is the current stratum number if the table has multiple strata. If the table has only one stratum, then the value is 0.

Requirement: The STRATNUM dynamic variable must be specified by the DYNAMIC statement before you can use the dynamic variable in an expression.
Featured in: Creating a Customized Crosstabulation Table Template with No Legend
STRATAVARIABLENAMES

is a string that identifies the current stratum by the name of the stratum variables.

var-1=value-1<var-n=value-n>
var-1-var-n

specifies the stratum variables.

value-1-value-n

specifies the values of the stratum variables.

Tip: The value is undefined if the table has only one stratum.
Requirement: The DYNAMIC statement must specify the STRATAVARIABLELABELS dynamic variables before the dynamic variables can be used in an expression.
STRATAVARIABLELABELS

is a string that identifies the current stratum by the label of the stratum variables.

var-1=value-1<var-n=value-n>
var-1-var-n

specifies the stratum variables.

value-1-value-n

specifies the values of the stratum variables.

Tip: The value is undefined when the table has only one stratum.
Requirement: The DYNAMIC statement must specify the STRATAVARIABLELABELS dynamic variables before you can use the dynamic variables in an expression.
Featured in: Creating a Customized Crosstabulation Table Template with No Legend and Creating a Crosstabulation Table Template with a Customized Legend

NOTES Statement


Provides information about the column.
Tip: The NOTES statement becomes part of the compiled column template, which you can view with the SOURCE statement. The SAS comments do not become part of the template.

NOTES 'text';

Required Arguments

'text'

provides information about the column.


TEXT Statement


Specifies the text of the header or the footer.
Featured in: Creating a Customized Crosstabulation Table Template with No Legend

TEXT header-specification(s) </ option(s)>;


Required Arguments

header-specification(s)

specifies the text of the header. header-specification(s) can be any dynamic variable that is specified by the DYNAMIC statement, or it can be one of the following:

dynamic-variable

is a variable that is automatically defined by SAS in the crosstabulation template. dynamic-variable can be one of the following:

_COL_LABEL_

is the label of the column variable, which is the last variable in a table request.

_COL_NAME_

is the name of the column variable, which is the last variable in a table request. If the column variable does not have a name, then the value of _COL_LABEL_ is an empty text string (" ").

_ROW_LABEL_

is the label of the row variable, which is the next to the last variable in a table request. If the row variable does not have a label, the value of _ROW_LABEL_ is an empty text string (" ").

_ROW_NAME_

is the name of the row variable, which is the next to the last variable in a table request.

text-specification(s)

specifies the text to use in the header. Each text-specification is one of the following:

  • a quoted string

  • a variable followed by an optional format. The variable is any variable that is declared in a DYNAMIC statement or is any of the variables above.

Tip: If the quoted string is a blank and it is the only item in the header specification, the header is a blank line.

Options

expression

is an expression that is evaluated for a header or footer. If expression is omitted, the default is 1. Each DEFINE HEADER statement can contain any number of TEXT statements. The template evaluates each expression in turn from top to bottom and thereby determines the text of the header. The header-specification in the first TEXT statement whose expression evaluates to true becomes the header text. After an expression evaluates to true, the template examines no more TEXT statements. If no expression is true, then the header is not used.

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 a number or text string.

dynamic variable

is a variable that is defined by SAS in the crosstabulation template or by the DYNAMIC statement within a header or footer template.

_COL_LABEL_

specifies the label of the column variable, which is the last variable in a table request. If the column variable does not have a label, then the value of _COL_LABEL_ is an empty text string (" ").

_COL_NAME_

specifies the name of the column variable, which is the last variable in a table request. If the column variable does not have a name, then the value of _COL_NAME_ is an empty text string (" ").

FMISSING

is the number of missing values in the table.

Requirement: The FMISSING dynamic variable must be specified by the DYNAMIC statement before you can use it in an expression.
NOTITLE

is set to 1 if PROC FREQ's NOTITLE option was used, and it is set to 0 if the NOTITLE option was not used.

Requirement: The NOTITLE dynamic variable must be specified by the DYNAMIC statement before you can use it in an expression.
_ROW_LABEL_

is the label of the row variable, which is the next to the last variable in a table request. If the row variable does not have a name, then the value of _ROW_LABEL_ is an empty text string (" ").

_ROW_NAME_

specifies the name of the row variable, which is the next to the last variable in a table request. If the row variable does not have a name, then the value of _ROW_NAME_ is an empty text string (" ").

SAMPLESIZE

is set to 0 if the table is empty. Otherwise, it is set to 1.

Requirement: The SAMPLESIZE dynamic variable must be specified by the DYNAMIC statement before you can use it in an expression.
STRATNUM

is the current stratum number if the table has multiple strata. If the table has only one stratum, then the value is 0.

Requirement: The STRATNUM dynamic variable must be specified by the DYNAMIC statement before you can use it in an expression.
STRATAVARIABLENAMES

is a string that identifies the current stratum by the name of the stratum variables.

var-1=value-1<var-n=value-n>
var-1-var-n

specifies the stratum variables.

value-1-value-n

specifies the values of the stratum variables.

Tip: The value is undefined when the table has only one stratum.
Requirement: The STRATAVARIABLENAMES dynamic variable must be specified by the DYNAMIC statement before you can use it in an expression.
STRATAVARIABLELABELS

is a string that identifies the current stratum by the label of the stratum variables. STRATAVARIABLELABELS has the following form:

var-1=value-1<var-n=value-n?>
var-1-var-n

specifies the stratum variables.

value-1-value-n

specifies the values of the stratum variables.

Tip: The value is undefined when the table has only one stratum.
Requirement: The DYNAMIC statement must specify the STRATAVARIABLELABELS dynamic variables before you can use them in an expression.
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


END Statement


END;

Previous Page | Next Page | Top of Page