TEMPLATE Procedure: Creating Crosstabulation Table Templates

DEFINE CROSSTABS Statement

Creates a crosstabulation table template.
Note: The DEFINE CROSSTABS statement begins a crosstabs table template. The following statements are typically used within a DEFINE CROSSTABS block: CELLVALUE Statement, DEFINE CELLVALUE Statement, DEFINE HEADER Statement, DEFINE FOOTER Statement, DYNAMIC Statement, FOOTER Statement, HEADER Statement, and NOTES Statement.
Creating a Customized Crosstabulation Table Template with No Legend

Syntax

DEFINE CROSSTABS table-path </ STORE=libref.template-store>;
CELLVALUE cellvalues;
DEFINE CELLVALUE cellvalue;
statements-and-attributes;
END;
DEFINE HEADER header-name;
statements-and-attributes;
END;
DEFINE FOOTER footer-name;
statements-and-attributes;
END;
DYNAMIC variable-1 <'text-1'> <variable-n <'text-n'>>;
FOOTER footer-name(s);
HEADER header-name(s);
NOTES text;
END;

Summary of Optional Arguments

Specify a style element and any changes to its attributes to use for the cellvalues in the non-summary rows and columns
Specify the style element and any changes to its attributes to use for the cellvalues in the last row in the table
Specify the style element and any changes to its attributes to use for the column variable values used as headers over the column variable value columns
Specify the name of the header to use over the column variable value columns in the table
Specify the style element and any changes to its attributes to use for the cellvalues in the rightmost column of the last row in the table
Specify a label for the table
Specify the style element and any changes to its attributes to use for the legend table that appears near the upper left corner of the table
Specify the style element and any changes to its attributes to use for the cellvalues in the cells that contain row totals
Specify the style element and any changes to its attributes to use for the row variable values in the leftmost column of the table
Specify the name of the header to use over the row variable values (leftmost) column in the table
Specify the template store in which to store the crosstabulation template.
Specify a style element and any changes to its attributes to use for the table

Required Argument

table-path
specifies where to store the crosstabulation table template. A table-path consists of one or more names, separated by periods. Each name represents a directory in a template store, which is a type of SAS file. For more information about template stores, see Understanding Item Stores, Template Stores, and Directories. PROC TEMPLATE writes the template to the first writable template store in the current path.
Requirement:Crosstabulation table templates must be named CrossTabFreqs.

Optional Argument

STORE= template-store
specifies the template store in which to store the crosstabulation template. If the template store does not exist, it is created.
Restrictions:The STORE= option does not become part of the template.

If the template is nested inside another template, do not use the STORE= option for the nested template, because the nested template is stored where the original template is stored.

Requirement:The STORE= option must be proceeded by the forward slash (/) symbol.

DEFINE CROSSTABS Attributes

This section lists all of the attributes that you can use in a crosstabulation template.
Crosstabulation Attributes
Task
Statement
Specify a style element and any changes to its attributes to use for the cellvalues in the non-summary rows and columns
CELL_STYLE=
Specify the name of the header to use over the column variable value columns in the table
COLS_HEADER=
Specify the style element and any changes to its attributes to use for the cellvalues in the last row in the table
COL_TOTAL_STYLE=
Specify the style element and any changes to its attributes to use for the column variable values used as headers over the column variable value columns
COL_VAR_STYLE=
Specify the style element and any changes to its attributes to use for the cellvalues in the rightmost column of the last row in the table
GRAND_TOTAL_STYLE=
Specify a label for the table
LABEL=
Specify the style element and any changes to its attributes to use for the legend table that appears near the upper left corner of the table
LEGEND_STYLE=
Specify the name of the header to use over the row variable values (leftmost) column in the table
ROWS_HEADER=
Specify the style element and any changes to its attributes to use for the cellvalues in the cells that contain row totals
ROW_TOTAL_STYLE=
Specify the style element and any changes to its attributes to use for the row variable values in the leftmost column of the table
ROW_VAR_STYLE=
Specify a style element and any changes to its attributes to use for the table
STYLE=
CELL_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes that you can use for the cellvalues in the non-summary rows and columns. This refers to the cellvalues that are not in the row totals column (see ROW_TOTAL_STYLE), the column totals row (see COL_TOTAL_STYLE), or the grand total cell (see GRAND_TOTAL_STYLE).
Default:Data
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
COLS_HEADER=header-name
specifies the name of the header to use over the column variable value columns in the table.
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
COL_TOTAL_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the cellvalues in the last row in the table.
Default:Data
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
COL_VAR_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the column variable values used as headers over the column variable value columns.
Default:Header
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
GRAND_TOTAL_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the cellvalues in the rightmost column of the last row in the table.
Default:Data
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
LABEL="text"
specifies a label for the table.
Default:"Frequency Counts and Percentages"
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
LEGEND_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the legend table that appears near the upper left corner of the table.
Default:Header
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
ROWS_HEADER=header-name
specifies the name of the header to use over the row variable values (leftmost) column in the table.
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
ROW_TOTAL_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the cellvalues that contain row totals.
Default:Data
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
ROW_VAR_STYLE=<style-element-name><[style-attribute-specification(s)]>
specifies the style element and any changes to its attributes to use for the row variable values in the leftmost column of the table.
Default:RowHeader
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.
STYLE=<style-element-name><[style-attribute-specification(s)]>
Specifies the style element and any changes to its attributes to use for the table.
style-element-name
is the name of the style element to use to display the table. The style element must be part of a style that is registered with the Output Delivery System. SAS provides some style. You can create customized styles with PROC TEMPLATE (see DEFINE STYLE Statement). By default, ODS produces different parts of ODS output with different elements. For example, by default, a table is produced with the style element Table. The Table style element that SAS is provides is uniquely designed to describe elements necessary to a table. However, you might have a user-defined style element at your site that would be appropriate to specify.
The style element provides the basis for displaying the table. Additional style attributes that you provide can modify the display.
style-element-name is either the name of a style element or a variable whose value is a style element.

Finding and Viewing the Default Style for ODS Destinations

Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.

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

Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.

Default:Table
See:Crosstabulation Table Regions and Corresponding Attributes to see an illustration of the crosstabulation table regions and the DEFINE CROSSTABS attributes that affect each region.