specify the frequency and crosstabulation tables to produce. A request is composed of one variable name or several variable names separated by asterisks. To request a one-way frequency table, use a single variable. To request a two-way crosstabulation table, use an asterisk between two variables. To request a multiway table (an n-way table, where n > 2), separate the variables with asterisks. The unique values of these variables form the rows, columns, and strata of the table. You can include up to 50 variables in a single multiway table request.
For two-way to multiway tables, the values of the last variable form the crosstabulation table columns, and the values of the next-to-last variable form the rows. Each level (or combination of levels) of the other variables forms one stratum. PROC FREQTAB produces a separate crosstabulation table for each stratum. For example, a specification of A*B*C*D in a TABLES statement produces k tables, where k is the number of different combinations of values for A and B. Each table lists the values for C down the side and the values for D across the top.
You can use multiple TABLES statements in the PROC FREQTAB step. PROC FREQTAB builds all the table requests in one pass of the data, so that there is essentially no loss of efficiency. You can also specify any number of table requests in a single TABLES statement. To specify multiple table requests quickly, use a grouping syntax by placing parentheses around several variables and joining other variables or variable combinations. For example, the statements shown in Table 5.7 illustrate grouping syntax.
Table 5.7: Grouping Syntax
TABLES Request | Equivalent to |
|---|
A*(B C)
| A*B A*C |
(A B)*(C D) | A*C B*C A*D B*D |
(A B C)*D | A*D B*D C*D |
A – C
| A B C |
(A – C)*D | A*D B*D C*D |
The TABLES statement variables are one or more variables from the DATA= input data set. These variables can be either character or numeric, but the procedure treats them as categorical variables. PROC FREQTAB uses the formatted values of the TABLES variable to determine the categorical variable levels. For more information, see the discussion of the FORMAT procedure in the Base SAS Procedures Guide and the discussion of SAS formats in SAS Formats and Informats: Reference.
By default, the frequency or crosstabulation table lists the values of both character and numeric variables in ascending order based on internal (unformatted) variable values. You can change the order of the values in the table by specifying the ORDER= option in the PROC FREQTAB statement. To list the values in ascending order by formatted value, use ORDER=FORMATTED.