CARDINALITY Procedure

PROC CARDINALITY Statement

  • PROC CARDINALITY OUTCARD=libref.data-table <options>;

The PROC CARDINALITY statement invokes the procedure. Table 3 summarizes the options available in the PROC CARDINALITY statement.

Table 3: PROC CARDINALITY Statement Options

Option Description
Input and Output Data Sets
DATA= Specifies the input data table
OUTCARD= Names the cardinality data table to contain the summary information for each variable
OUTDETAILS= Names an optional data table to contain the detailed levels of all the variables
Cardinality Options
MAXLEVELS= Specifies the maximum number of levels to consider
ORDER= Specifies the order to be applied to all variables that have an unspecified order


You must specify the following option:

OUTCARD=libref.data-table

specifies the output data table to contain the cardinality and summary information for each variable. libref.data-table is a two-level name, where libref refers to the library, and data-table specifies the name of the output data table. For more information about this two-level name, see the DATA= option and the section Using SAS Viya Workbench.

You can also specify the following options:

DATA=libref.data-table

names the input data table for PROC CARDINALITY to use. libref.data-table is a two-level name, where

libref

refers to a collection of information that is defined in the LIBNAME statement and includes the library, which includes a path to the data. For more information about libref, see the section Using SAS Viya Workbench.

data-table

specifies the name of the input data table.

MAXLEVELS=number

specifies the maximum number of levels of the variables in the input data to consider. The number should be between 5 and 254.

By default, MAXLEVELS=20.

ORDER=ASC |DESC |ASCFMT |DESFMT

specifies the order to be applied to all variables whose order is not specified in a VAR statement.

You can specify the following values:

ASC

orders variables in unformatted ascending order.

DESC

orders variables in unformatted descending order.

ASCFMT

orders variables in formatted ascending order.

DESFMT

orders variables in formatted descending order.

By default, ORDER=ASC.

OUTDETAILS=libref.data-table

specifies the output data table to contain the levels that are found for each variable. libref.data-table is a two-level name, where libref refers to the library, and data-table specifies the name of the input data table. For more information about this two-level name, see the DATA= option and the section Using SAS Viya Workbench.

All the levels that are higher than the value of the MAXLEVELS= option are grouped together into one level that has a missing value (.) in the _INDEX_ column in the output data table. For this level, the corresponding raw and formatted levels contain the last values visible in the histogram. This is useful when you need the next segment of the histogram past the visible levels of a variable.

Last updated: May 14, 2026