Chapter Contents

Previous

Next
The TABULATE Procedure

CLASS Statement


Identifies class variables for the table. Class variables determine the categories that PROC TABULATE uses to calculate statistics.

Tip: You can use multiple CLASS statements.
Tip: Some CLASS statement options are also available in the PROC TABULATE statement. They affect all CLASS variables rather than just the one(s) that you specify in a CLASS statement.


CLASS variable(s) </option(s)>;


Required Arguments

variable(s)
specifies one or more variables that the procedure uses to group the data. Variables in a CLASS statement are referred to as class variables. Class variables can be numeric or character. Class variables can have continuous values, but they typically have a few discrete values that define the classifications of the variable. You do not have to sort the data by class variables.


Options

ASCENDING
specifies to sort the class variable values in ascending order.
Alias: ASCEND
Interaction: PROC TABULATE issues a warning message if you specify both ASCENDING and DESCENDING and ignores both options.

DESCENDING
specifies to sort the class variable values in descending order.
Alias: DESCEND
Default: ASCENDING
Interaction: PROC TABULATE issues a warning message if you specify both ASCENDING and DESCENDING and ignores both options.

EXCLUSIVE
excludes from tables and output data sets all combinations of class variables that are not found in the preloaded range of user-defined formations.
Requirement: You must specify the PRELOADFMT option in the CLASS statement to preload the class variable formats.
Featured in: Using Preloaded Formats with Class Variables

GROUPINTERNAL
specifies not to apply formats to the class variables when PROC TABULATE groups the values to create combinations of class variables.
Interaction: If you specify the PRELOADFMT option in the CLASS statement, PROC TABULATE ignores the GROUPINTERNAL option and uses the formatted values.
Tip: This option saves computer resources when the class variables contain discrete numeric values.

MISSING
considers missing values as valid class variable levels. Special missing values that represent numeric values (the letters A through Z and the underscore (_) character) are each considered as a separate value.
Default: If you omit MISSING, PROC TABULATE excludes the observations with any missing CLASS variable values from tables and output data sets.
See also: SAS Language Reference: Concepts for a discussion of missing values with special meanings.

MLF
enables PROC TABULATE to use the primary and secondary format labels for a given range or overlapping ranges to create subgroup combinations when a multilabel format is assigned to a class variable.
Requirement: You must use PROC FORMAT and the MULTILABEL option in the VALUE statement to create a multilabel format.
Interaction: Using MLF with ORDER=FREQ may not produce the order that you expect for the formatted values.
Tip: If you omit MLF, PROC TABULATE uses the primary format labels, which corresponds to the first external format value, to determine the subgroup combinations.
See also: The MULTILABEL option in the VALUE statement of the FORMAT procedure.
Featured in: Using Multilabel Formats

Note:   When the formatted values overlap, one internal class variable value maps to more than one class variable subgroup combination. Therefore, the sum of the N statistics for all subgroups is greater than the number of observations in the data set (the overall N statistic).  [cautionend]

ORDER=DATA | FORMATTED | FREQ | UNFORMATTED
specifies the order to group the levels of the class variables in the output, where

DATA
orders values according to their order in the input data set.
Interaction: If you use PRELOADFMT, the order for the values of each class variable matches the order that PROC FORMAT uses to store the values of the associated user-defined format. If you use the CLASSDATA= option in the PROC statement, PROC MEANS uses the order of the unique values of each class variable in the CLASSDATA= data set to order the output levels. If you use both options, PROC TABULATE first uses the user-defined formats to order the output. If you omit EXCLUSIVE in the PROC statement, PROC TABULATE appends after the user-defined format and the CLASSDATA= values the unique values of the class variables in the input data set based on the order that they are encountered.
Tip: By default, PROC FORMAT stores a format definition in sorted order. Use the NOTSORTED option to store the values or ranges of a user-defined format in the order that you define them.

FORMATTED
orders values by their ascending formatted values. This order depends on your operating environment.
Alias: FMT | EXTERNAL

FREQ
orders values by descending frequency count.
Interaction: Use the ASCENDING option to order values by ascending frequency count.

UNFORMATTED
orders values by their unformatted values, which yields the same order as PROC SORT. This order depends on your operating environment. This sort sequence is particularly useful for displaying dates chronologically.
Alias: UNFMT | INTERNAL

Default: UNFORMATTED
Interaction: If you use the PRELOADFMT option in the CLASS statement, PROC TABULATE orders the levels by the order of the values in the user-defined format.
Tip: By default, all orders except FREQ are ascending. For descending orders, use the DESCENDING option.
Featured in: Understanding the Order of Headings with ORDER=DATA

PRELOADFMT
specifies that all formats are preloaded for the class variables.
Requirement: PRELOADFMT has no effect unless you specify either EXCLUSIVE, ORDER=DATA, or PRINTMISS and you assign formats to the class variables.

Note:   If you specify PRELOADFMT without also specifying either EXCLUSIVE or PRINTMISS, SAS writes a warning message to the SAS log.  [cautionend]

Interaction: To limit PROC TABULATE output to the combinations of formatted class variable values present in the input data set, use the EXCLUSIVE option in the CLASS statement.
Interaction: To include all ranges and values of the user-defined formats in the output, use the PRINTMISS option in the TABLE statement.
CAUTION:
Use care when you use PRELOADFMT with PRINTMISS. This feature creates all possible combinations of formatted class variables. Some of these combinations may not make sense.  [cautionend]
Featured in: Using Preloaded Formats with Class Variables

STYLE=<style-element-name | <PARENT>><[style-attribute-specification(s)]>
specifies the style element to use for page dimension text, continuation messages, and class variable name headings. For information about the arguments of this option, and how it is used, see STYLE= in the PROC TABULATE statement.

Note:   When you use STYLE= in the CLASS statement, it differs slightly from its use in the PROC TABULATE statement. In the CLASS statement, the parent of the heading is the page dimension text or heading under which the current heading is nested.   [cautionend]

Note:   If a page dimension expression contains multiple nested elements, the Beforecaption style element is the style element of the first element in the nesting.  [cautionend]
Alias: S=
Restriction: This option affects only the HTML and Printer output.
Tip: To override a style element that is specified for page dimension text in the CLASS statement, you can specify a style element in the TABLE statement page dimension expression.
Tip: To override a style element that is specified for a class variable name heading in the CLASS statement, you can specify a style element in the related TABLE statement dimension expression.
Featured in: Specifying Style Elements for HTML Output


How PROC TABULATE Handles Missing Values for Class Variables
By default, if an observation contains a missing value for any class variable, PROC TABULATE excludes that observation from all tables that it creates. CLASS statements apply to all TABLE statements in the PROC TABULATE step. Therefore, if you define a variable as a class variable, PROC TABULATE omits observations that have missing values for that variable from every table even if the variable does not appear in the TABLE statement for one or more tables.

If you specify the MISSING option in the PROC TABULATE statement, the procedure considers missing values as valid levels for all class variables. If you specify the MISSING option in a CLASS statement, PROC TABULATE considers missing values as valid levels for the class variable(s) that are specified in that CLASS statement.


Chapter Contents

Previous

Next

Top of Page

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