TABULATE Procedure

TABLE Statement

Describes a table to print.
Requirement: All variables in the TABLE statement must appear in either the VAR statement or the CLASS statement.
Tips: To create several tables use multiple TABLE statements.

Use of variable name list shortcuts is now supported within the TABLE statement. For more information, see Shortcuts for Specifying Lists of Variable Names.

Creating a Basic Two-Dimensional Table

Using Preloaded Formats with Class Variables

Using Multilabel Formats

Customizing Row and Column Headings

Summarizing Information with the Universal Class Variable ALL

Eliminating Row Headings

Indenting Row Headings and Eliminating Horizontal Separators

Creating Multipage Tables

Reporting on Multiple-Response Survey Data

Reporting on Multiple-Choice Survey Data

Calculating Various Percentage Statistics

Using Denominator Definitions to Display Basic Frequency Counts and Percentages

Specifying Style Elements for ODS Output

Style Precedence

NOCELLMERGE Option

Syntax

Required Argument

column-expression
defines the columns in the table. For information about constructing dimension expressions, see Details.
Restriction:A column dimension is the last dimension in a TABLE statement. A row dimension or a row dimension and a page dimension can precede a column dimension.

Optional Arguments

page-expression
defines the pages in a table. For information about constructing dimension expressions, see Details.
Restriction:A page dimension is the first dimension in a table statement. Both a row dimension and a column dimension must follow a page dimension.
row-expression
defines the rows in the table. For information about constructing dimension expressions, see Details.
Restriction:A row dimension is the next to last dimension in a table statement. A column dimension must follow a row dimension. A page dimension can precede a row dimension.

Table Options

BOX=value
BOX={<label=value> <STYLE=<style-element-name>[style-attribute-name=style-attribute-value<… style-attribute-name=style-attribute-value>]>}
specifies text and a style element for the empty box above the row titles.
Value can be one of the following:
_PAGE_
writes the page-dimension text in the box. If the page-dimension text does not fit, then it is placed in its default position above the box, and the box remains empty.
'string'
writes the quoted string in the box. Any string that does not fit in the box is truncated.
variable
writes the name (or label, if the variable has one) of a variable in the box. Any name or label that does not fit in the box is truncated.
For details about the arguments of the STYLE= option and how it is used, see STYLE= in the PROC TABULATE statement.
CONDENSE
prints as many complete logical pages as possible on a single printed page or, if possible, prints multiple pages of tables that are too wide to fit on a page one below the other on a single page, instead of on separate pages. A logical page is all the rows and columns that fall within one of the following:
  • a page-dimension category (with no BY-group processing)
  • a BY group with no page dimension
  • a page-dimension category within a single BY group
Restriction:CONDENSE has no effect on the pages that are generated by the BY statement. The first table for a BY group always begins on a new page.
CONTENTS=link-name
enables you to name the link in the HTML table of contents that points to the ODS output of the table that is produced by using the TABLE statement.
Note: CONTENTS= affects only the contents file of ODS HTML output. It has no effect on the actual TABULATE procedure reports.
FORMAT_PRECEDENCE=PAGE|ROW|COLUMN|COL
specifies whether the format that is specified for the page dimension (PAGE), row dimension (ROW), or column dimension (COLUMN or COL) is applied to the contents of the table cells.
Default:COLUMN
FUZZ=number
supplies a numeric value against which analysis variable values and table cell values other than frequency counts 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. The default value is the smallest representable floating-point number on the computer that you are using.
INDENT=number-of-spaces
specifies the number of spaces to indent nested row headings, and suppresses the row headings for class variables.
Restriction:In the HTML, RTF, and Printer destinations, the INDENT= option suppresses the row headings for class variables but does not indent nested row headings.
Tip:When there are no crossings in the row dimension, there is nothing to indent, so the value of number-of-spaces has no effect. However, in such cases INDENT= still suppresses the row headings for class variables.
MISSTEXT='text'
MISSTEXT={<label='text'> <STYLE=<style-element-name> [style-attribute-name=style-attribute-value <... style-attribute-name=style-attribute-value>]>}
supplies up to 256 characters of text to print and specifies a style element for table cells that contain missing values. For details about the arguments of the STYLE= option and how it is used, see STYLE= in the PROC TABULATE statement.
Interaction:A style element that is specified in a dimension expression overrides a style element that is specified in the MISSTEXT= option for any given cells.
NOCELLMERGE
specifies that data cells are not merged with other data cells in the table.
Note: The NOCELLMERGE option works with the ODS formatted destinations. These include the ODS MARKUP family, ODS RTF, and the ODS PRINTER family destinations.
Restriction:The NOCELLMERGE does not work with the traditional monospace output.
Interactions:If you specify ROW=FLOAT or INDENT=0, PROC TABULATE produces single unmerged data rows. The NOCELLMERGE option is then ignored because there are no rows that need to be merged.

If the NOCELLMERGE option is in effect, the style of the empty data cells will be the default style of the data cell. The style of the empty data cells might not be the same style as the style of the formatted data cells.

NOCONTINUED
suppresses the continuation message, continued, that is displayed at the bottom of tables that span multiple pages. The text is rendered with the AFTERCAPTION style element.
Note: Because HTML browsers do not break pages, NOCONTINUED has no effect on the HTML destination.
PRINTMISS
prints all values that occur for a class variable each time headings for that variable are printed, even if there are no data for some of the cells that these headings create. Consequently, PRINTMISS creates row and column headings that are the same for all logical pages of the table, within a single BY group.
Default:If you omit PRINTMISS, then PROC TABULATE suppresses a row or column for which there are no data, unless you use the CLASSDATA= option in the PROC TABULATE statement.
Restriction:If an entire logical page contains only missing values, then that page does not print regardless of the PRINTMISS option.
ROW=spacing
specifies whether all title elements in a row crossing are allotted space even when they are blank. The possible values for spacing are as follows:
CONSTANT
allots space to all row titles even if the title has been blanked out. (For example, N=' '.)
Alias:CONST
FLOAT
divides the row title space equally among the nonblank row titles in the crossing.
Default:CONSTANT
RTSPACE=number
specifies the number of print positions to allot to all of the headings in the row dimension, including spaces that are used to print outlining characters for the row headings. PROC TABULATE divides this space equally among all levels of row headings.
Alias:RTS=
Default:one-fourth of the value of the SAS system option LINESIZE=
Restriction:The RTSPACE= option affects only the traditional SAS monospace output destination.
Interaction:By default, PROC TABULATE allots space to row titles that are blank. Use ROW=FLOAT in the TABLE statement to divide the space among only nonblank titles.
See:For more examples of controlling the space for row titles, see PROC TABULATE by Example, Second Edition.
STYLE=<style-element-name> [style-attribute-name=style-attribute-value<… style-attribute-name=style-attribute-value>]
specifies a style element to use for parts of the table other than table cells. See STYLE= in the PROC TABULATE statement for information about the style element arguments.
Note: You can use braces ({ and }) instead of square brackets ([ and ]).
The following table shows the attributes that you can set or change with the STYLE= option in the TABLE statement. Most of these attributes apply to parts of the table other than cells (for example, table borders and the lines between columns and rows). Attributes that you apply in the PROC TABULATE statement and in other locations in the PROC TABULATE step apply to cells within the table. Note that not all attributes are valid in all destinations. See Style Attributes Tables in SAS Output Delivery System: User's Guide for information about these style attributes, their valid values, and their applicable destinations.
Style Attributes for PROC REPORT and PROC TABULATE
Attribute
PROC REPORT STATEMENT: REPORT Area
PROC REPORT Areas: CALLDEF, COLUMN, HEADER, LINES, SUMMARY
PROC TABULATE STATEMENT: TABLE
PROC TABULATE STATEMENTS: VAR, CLASS, BOXOpt, CLASSLEV, KEYWORD
ASIS=
X
X
X
BACKGOUNDCOLOR=
X
X
X
X
BACKGOUNDIMAGE=
X
X
X
X
BORDERBOTTOMCOLOR=
X
X
X
BORDERBOTTOMSTYLE=
X
X
X
X
BORDERBOTTOMWIDTH=
X
X
X
X
BORDERCOLOR=
X
X
X
BORDERCOLORDARK=
X
X
X
X
BORDERCOLORLIGHT=
X
X
X
X
BORDERTOPCOLOR=
X
X
X
BORDERTOPSTYLE=
X
X
X
X
BORDERTOPWIDTH=
X
X
X
X
BORDERWIDTH=
X
X
X
X
CELLPADDING=
X
X
CELLSPACING=
X
X
CELLWIDTH=
X
X
X
X
CLASS=
X
X
X
X
COLOR=
X
X
X
FLYOVER=
X
X
X
FONT=
X
X
X
X
FONTFAMILY=
X
X
X
X
FONTSIZE=
X
X
X
X
FONTSTYLE=
X
X
X
X
FONTWEIGHT=
X
X
X
X
FONTWIDTH=
X
X
X
X
FRAME=
X
X
HEIGHT=
X
X
X
HREFTARGET=
X
X
HTMLSTYLE=
X
X
X
X
NOBREAKSPACE=
X
X
X
OUTPUTWIDTH=
X
X
X
X
POSTHTML=
X
X
X
X
POSTIMAGE=
X
X
X
X
POSTTEXT=
X
X
X
X
PREHTML=
X
X
X
X
PREIMAGE=
X
X
X
X
PRETEXT=
X
X
X
X
PROTECTSPECIALCHARS=
X
X
RULES=
X
X
TAGATTR=
X
X
X
TEXTALIGN=
X
X
X
X
URL=
X
X
VERTICALALIGN=
X
X
WIDTH=
X
X
X
X
Note: The list of attributes that you can set or change with the STYLE= option in the TABLE statement differs from the list of attributes of the PROC TABULATE statement.
Alias:S=
Restriction:This option affects only the HTML, RTF, and Printer destinations.
Tip:To override a style element specification that is made as an option in the TABLE statement, specify STYLE= in a dimension expression of the TABLE statement.
STYLE_PRECEDENCE=PAGE|ROW|COLUMN|COL
specifies whether the style that is specified for the page dimension (PAGE), row dimension (ROW), or column dimension (COLUMN or COL) is applied to the contents of the table cells.
Default:COLUMN

Details

What Are Dimension Expressions?

A dimension expression defines the content and appearance of a dimension (the columns, rows, or pages in the table) by specifying the combination of variables, variable values, and statistics that make up that dimension. A TABLE statement consists of from one to three dimension expressions separated by commas. Options can follow the dimension expressions.
If all three dimensions are specified, then the leftmost dimension expression defines pages, the middle dimension expression defines rows, and the rightmost dimension expression defines columns. If two dimensions are specified, then the left dimension expression defines rows, and the right dimension expression defines columns. If a single dimension is specified, then the dimension expression defines columns.
A dimension expression consists of one or more elements and operators.

Elements That You Can Use in a Dimension Expression

analysis variables
(See the VAR statement .)
class variables
(See the CLASS statement .)
the universal class variable ALL
summarizes all of the categories for class variables in the same parenthetical group or dimension (if the variable ALL is not contained in a parenthetical group).
Note: If the input data set contains a variable named ALL, then enclose the name of the universal class variable in quotation marks.
keywords for statistics
See Statistics That Are Available in PROC TABULATE for a list of available statistics. Use the asterisk (*) operator to associate a statistic keyword with a variable. The N statistic (number of nonmissing values) can be specified in a dimension expression without associating it with a variable.
Default:For analysis variables, the default statistic is SUM. Otherwise, the default statistic is N.
Restriction:Statistic keywords other than N must be associated with an analysis variable.
Interaction:Statistical keywords should be enclosed by single or double quotation marks to ensure that the keyword element is treated as a statistical keyword and not treated as a variable. By default, SAS treats these keywords as variables.
Example:
n
Region*n
Sales*max
format modifiers
define how to format values in cells. Use the asterisk (*) operator to associate a format modifier with the element (an analysis variable or a statistic) that produces the cells that you want to format. Format modifiers have the form
f=format
Tip:Format modifiers have no effect on CLASS variables.
See:For more information about specifying formats in tables, see Formatting Values in Tables.
Example:
Sales*f=dollar8.2
labels
temporarily replace the names of variables and statistics. Labels affect only the variable or statistic that immediately precedes the label. Labels have the form
statistic-keyword-or-variable-name='label-text'
Tip:PROC TABULATE eliminates the space for blank column headings from a table but by default does not eliminate the space for blank row headings unless all row headings are blank. Use ROW=FLOAT in the TABLE statement to remove the space for blank row headings.
Example:
Region='Geographical Region'
Sales*max='Largest Sale'
style-element specifications
specify style elements for page dimension text, headings, or data cells. For details, see Specifying Style Elements in Dimension Expressions.

Operators That You Can Use in a Dimension Expression

asterisk *
creates categories from the combination of values of the class variables and constructs the appropriate headings for the dimension. If one of the elements is an analysis variable, then the statistics for the analysis variable are calculated for the categories that are created by the class variables. This process is called crossing.
Example:
Region*Division
Quarter*Sales*f=dollar8.2
(blank)
places the output for each element immediately after the output for the preceding element. This process is called concatenation.
parentheses ()
group elements and associate an operator with each concatenated element in the group.
Example:
Division*(Sales*max Sales*min)
(Region ALL)*Sales
angle brackets <>
specify denominator definitions, which determine the value of the denominator in the calculation of a percentage. For a discussion of how to construct denominator definitions, see Calculating Percentages .

Specifying Style Elements in Dimension Expressions

You can specify a style element in a dimension expression to control the appearance in HTML, RTF, and Printer output of the following table elements:
  • analysis variable name headings
  • class variable name headings
  • class variable level value headings
  • data cells
  • keyword headings
  • page dimension text
Specifying a style element in a dimension expression is useful when you want to override a style element that you have specified in another statement, such as the PROC TABULATE, CLASS, CLASSLEV, KEYWORD, TABLE, or VAR statements.
The syntax for specifying a style element in a dimension expression is
[STYLE<(CLASSLEV)>=<style-element-name | PARENT>
[style-attribute-name=style-attribute-value<… style-attribute-name=style-attribute-value>]]
Some examples of style elements in dimension expressions are
  • dept={label='Department'
          style=[color=red]}, N
  • dept*[style=MyDataStyle], N
  • dept*[format=12.2 style=MyDataStyle], N
Note: When used in a dimension expression, the STYLE= option must be enclosed within square brackets ([ and ]) or braces ({ and }).
With the exception of (CLASSLEV), all arguments are described in STYLE= in the PROC TABULATE statement.
(CLASSLEV)
assigns a style element to a class variable level value heading. For example, the following TABLE statement specifies that the level value heading for the class variable, DEPT, has a foreground color of yellow:
table dept=[style(classlev)=
            [color=yellow]]*sales;
Note: This option is used only in dimension expressions.
For an example that shows how to specify style elements within dimension expressions, see Specifying Style Elements for ODS Output.