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 40.4 lists the options available in the PROC FREQ statement. Descriptions of the options follow in alphabetical order.

Table 40.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 in the PROC FREQ statement.

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 be used for constructing the outlines and dividers for the cells of crosstabulation table displays. The formchar-string should be three characters long. The characters are used to draw the vertical separators (1), the horizontal separators (2), and the vertical-horizontal intersections (7). If you do not specify the FORMCHAR= option, PROC FREQ uses FORMCHAR(1,2,7)='|-+' by default. Table 40.5 summarizes the formatting characters used by PROC FREQ.

Table 40.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


The FORMCHAR= option can specify 20 different SAS formatting characters used to display output; however, PROC FREQ uses only the first, second, and seventh formatting characters. Therefore, the proper specification for PROC FREQ is FORMCHAR(1,2,7)= 'formchar-string'.

Specifying all blanks for formchar-string produces crosstabulation tables with no outlines or dividers—for example, FORMCHAR(1,2,7)=' '. You can use any character in formchar-string, including hexadecimal characters. If you use hexadecimal characters, you must put an x after the closing quote. For information about which hexadecimal codes to use for which characters, see the documentation for your hardware.

See the CALENDAR, PLOT, and TABULATE procedures in the Base SAS Procedures Guide for more information about form characters.

NLEVELS

displays the "Number of Variable Levels" table, which provides the number of levels for each variable named in the TABLES statements. See the section Number of Variable Levels Table for details. 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 20: 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 Language Reference: Concepts.

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.