The FREQ Procedure

PROC FREQ Statement

  • PROC FREQ <options> ;

The PROC FREQ statement invokes the FREQ procedure. Optionally, it also identifies the input data set. By default, the procedure uses the most recently created SAS data set.

Table 4 lists the options available in the PROC FREQ statement. Descriptions of the options follow in alphabetical order.

Table 4: PROC FREQ Statement Options

Option Description
COMPRESS Begins the next one-way table on the current page
DATA= Names the input data set
FORMCHAR= Specifies the outline and cell divider characters for crosstabulation tables
NLEVELS Displays the number of levels for all TABLES variables
NOPRINT Suppresses all displayed output
ORDER= Specifies the order for reporting variable values
PAGE Displays one table per page


You can specify the following options:

COMPRESS

begins display of the next one-way frequency table on the same page as the preceding one-way table if there is enough space to begin the table. By default, the next one-way table begins on the current page only if the entire table fits on that page. The COMPRESS option is not valid with the PAGE option.

DATA=SAS-data-set

names the SAS-data-set to be analyzed by PROC FREQ. If you omit the DATA= option, the procedure uses the most recently created SAS data set.

FORMCHAR(1,2,7)='formchar-string'

defines the characters to use to construct cell outlines and dividers for crosstabulation tables. This option affects only the SAS monospace output destination.

PROC FREQ uses 3 of the 20 formatting characters that SAS provides. You can specify three characters in formchar-string to draw the vertical separators (1), the horizontal separators (2), and the vertical-horizontal intersections (7) in crosstabulation tables. By default, PROC FREQ uses FORMCHAR(1,2,7)='|-+'. Table 5 summarizes the formatting characters that PROC FREQ uses.

Table 5: Formatting Characters Used by PROC FREQ

Position Default Used to Draw
1 | Vertical separators
2 - Horizontal separators
7 + Intersections of vertical and horizontal separators


To produce crosstabulation tables that have no cell outlines or dividers, you can specify all blanks in formchar-string—for example, FORMCHAR(1,2,7)='     ' (three blanks).

You can use any characters in formchar-string. If you use hexadecimal characters, you must put x after the closing quotation mark. For information about which hexadecimal codes to use for which characters, see the documentation for your hardware.

For more information about formatting characters, see the TABULATE procedure in the Base SAS Procedures Guide.

NLEVELS

displays the "Number of Variable Levels" table, which provides the number of levels for each variable named in the TABLES statements. For more information, see the section Number of Variable Levels Table. PROC FREQ determines the variable levels from the formatted variable values, as described in the section Grouping with Formats.

NOPRINT

suppresses the display of all output. You can use the NOPRINT option when you only want to create an output data set. See the section Output Data Sets for information about the output data sets produced by PROC FREQ. Note that the NOPRINT option temporarily disables the Output Delivery System (ODS). For more information, see Chapter 23, Using the Output Delivery System.

Note: A NOPRINT option is also available in the TABLES statement. It suppresses display of the crosstabulation tables but allows display of the requested statistics.

ORDER=DATA | FORMATTED | FREQ | INTERNAL

specifies the order of the variable levels in the frequency and crosstabulation tables, which you request in the TABLES statement.

The ORDER= option can take the following values:

Value of ORDER= Levels Ordered By
DATA Order of appearance in the input data set
FORMATTED External formatted value, except for numeric variables with no explicit format, which are sorted by their unformatted (internal) value
FREQ Descending frequency count; levels with the most observations come first in the order
INTERNAL Unformatted value

By default, ORDER=INTERNAL. The FORMATTED and INTERNAL orders are machine-dependent. The ORDER= option does not apply to missing values, which are always ordered first.

For more information about sort order, see the chapter on the SORT procedure in the Base SAS Procedures Guide and the discussion of BY-group processing in SAS Programmers Guide: Essentials.

PAGE

displays only one table per page. Otherwise, PROC FREQ displays multiple tables per page as space permits. The PAGE option is not valid with the COMPRESS option.

Last updated: December 09, 2022