Chapter Contents

Previous

Next
The FREQ Procedure

TABLES Statement


Requests one-way to n-way frequency and crosstabulation tables and computes the statistics for these tables.

Default: If you omit the TABLES statement, PROC FREQ generates one-way frequency tables for all data set variables that are not listed in the other statements.
Featured in: Creating an Output Data Set with Table Cell Frequencies


TABLES request(s) </ option(s)>;


Required Arguments

request(s)
specifies the frequency and crosstabulation tables to produce. A request is composed of one variable name or several variable names that are 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 desired variables with asterisks. The unique values of these variables form rows, columns, and strata of the table.

For two-way to multiway tables, the values of the last variable form the crosstabulation table columns while 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 FREQ produces a separate crosstabulation table for each stratum. For example, the TABLES statement request A*B*C*D 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 FREQ step. PROC FREQ 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 following statements illustrate grouping syntax:

Request Equivalent to
tables a*(b c);
tables a*b a*c;
tables (a b)*(c d);
tables a*c b*c a*d b*d;
tables (a b c)*d;
tables a*d b*d c*d;
tables a--c;
tables a b c;
tables (a--c)*d;
tables a*d b*d c*d;


Without Options
If you request a one-way frequency table for a variable without specifying options, PROC FREQ produces frequencies, cumulative frequencies, percentages of the total frequency, and cumulative percentages for each value of the variable. If you request a two-way or n-way crosstabulation table without specifying options, PROC FREQ produces crosstabulation tables that include cell frequencies, cell percentages of the total frequency, cell percentages of row frequencies, and cell percentages of column frequencies. The procedure excludes observations with missing values from the table, but displays the total frequency of missing observations below each table.


Options

To do this Use this option
Control statistical analysis

Request tests and measures of classification agreement AGREE

Request tests and measures of association produced by CHISQ, MEASURES, and CMH ALL

Set the confidence level for confidence limits ALPHA=

Request binomial proportion, confidence limits, and test for one-way tables BINOMIAL

Request chi-square tests and measures of association based on chi-square CHISQ

Request confidence limits for the MEASURES statistics CL

Request all Cochran-Mantel-Haenszel statistics, adjusted relative risks, and odds ratios CMH

Request adjusted relative risks and odds ratios and CMH correlation statistic CMH1

Request adjusted relative risks and odds ratios, CMH correlation, and row mean scores (ANOVA) statistic CMH2

Specify convergence criterion to compute polychoric correlation CONVERGE=

Request Fisher's exact test for tables larger than 2×2 FISHER

Request Jonckheere-Terpstra test JT

Specify maximum number of iterations to compute polychoric correlation MAXITER=

Request measures of association and their asymptotic standard errors MEASURES

Treat missing values as nonmissing MISSING

Request polychoric correlation PLCORR

Request relative risk measures for 2×2 tables RELRISK

Request risks and risk differences for 2×2 tables RISKDIFF

Specify the type of row and column scores SCORES=

Specify expected frequencies for a one-way table chi-square test TESTF=

Specify expected proportions for a one-way table chi-square test TESTP=

Request Cochran-Armitage test for trend TREND
Control additional table information

Report each cell's contribution to the total Pearson chi-square statistic CELLCHI2

Display the cumulative column percentage in each cell CUMCOL

Display the deviation of the cell frequency from the expected value for each cell DEVIATION

Display the expected cell frequency for each cell EXPECTED

Display missing value frequencies MISSPRINT

List all possible combinations of variable levels even when a combination does not occur SPARSE

Display percentage of total frequency on n-way tables when n>2 TOTPCT
Control displayed output

Suppress the column percentage for each cell NOCOL

Suppress the cumulative frequencies and the cumulative percentages in one-way frequency tables and in list format NOCUM

Suppress the frequency count for each cell NOFREQ

Suppress the percentage, row percentage, and column percentage in crosstabulation tables, or percentages and cumulative percentages in one-way frequency tables and in list format NOPERCENT

Suppress the display of tables but report the statistics NOPRINT

Suppress the row percentage for each cell NOROW

Display two-way to n-way tables in list format LIST

Display the kappa coefficient weights PRINTKWT

Display the row and the column scores SCOROUT

Use a field 8 positions wide to display the cell frequencies between 1.E7 and 1.E8 V5FMT
Create an output data set

Specify an output data set to contain variable values and frequency counts OUT=

Include the expected frequency of each cell in the output data set OUTEXPECT

Include the percentage of column frequency, row frequency, and two-way table frequency in the output data set OUTPCT

AGREE <(WT=type)>
requests tests and measures of classification agreement for square tables. The AGREE option provides McNemar's test for 2×2 tables and Bowker's test of symmetry for tables with more than two response categories. The AGREE option also produces the simple kappa statistic, the weighted kappa statistic, their asymptotic standard errors, and the corresponding confidence limits. When there are multiple strata, PROC FREQ computes overall simple and weighted kappa statistics, as well as tests for equal kappas among strata. When there are multiple strata and two response categories, PROC FREQ computes Cochran's Q test.

(WT=type)
specifies the type of weights that PROC FREQ uses to compute the weighted kappa coefficient, where type is the following:
CA Cicchetti-Allison weights
FC Fleiss-Cohen weights
Default: CA
Main discussion: Weighted Kappa Coefficient

Restriction: The table must be square.
Tip: You can specify PRINTKWT to display the kappa coefficient weights.
Main discussion: Tests and Measures of Agreement
Featured in: Testing Marginal Homogeneity with Cochran's Q

ALL
requests all tests and measures that are computed by the CHISQ, MEASURES, and CMH options.
Interaction: CMH1 and CMH2 control which CMH statistics PROC FREQ computes.

ALPHA=p
sets the confidence level for confidence limits. The percentage for the confidence limits is (1-p)×100. Using ALPHA=.05 results in 95 percent confidence limits. If p is between 0 and 1 but is outside the range, PROC FREQ uses the closest range endpoint. For example, if p=0.000001, PROC FREQ uses 0.0001 to determine confidence limits.
Default: 0.05
Range: 0.0001<=p<=0.9999

BINOMIAL <(P=value)>
computes the binomial proportion for one-way tables. This is the proportion of observations for the first variable level that appears in the output. BINOMIAL also computes the asymptotic standard error, asymptotic and exact confidence limits, and the asymptotic test for the binomial proportion. To specify the null hypothesis proportion value for the test, use P=.
Default: P=0.5
Restriction: for one-way tables
Interaction: To request an exact test for the binomial proportion, specify BINOMIAL in the EXACT statement.
Main Discussion: Binomial Proportion
Featured in: Computing Binomial Proportions for One-Way Frequency Tables

CELLCHI2
displays each cell's contribution to the total Pearson chi-square statistic, which is computed as (frequency - expected)2/expected.
Interaction: CELLCHI2 is valid for contingency tables but has no effect on tables that are produced with LIST.

CHISQ
computes chi-square tests of homogeneity or independence for two-way tables, and computes measures of association based on chi-square for two-way tables. The tests include Pearson chi-square, likelihood-ratio chi-square, and Mantel-Haenszel chi-square. The measures include the phi coefficient, the contingency coefficient, and Cramer's V. For 2×2 tables, CHISQ includes Fisher's exact test and the continuity-adjusted chi-square. For one-way tables, CHISQ computes a chi-square goodness-of-fit test for equal proportions. If you specify the null hypothesis proportions with the TESTP= option, then CHISQ computes a chi-square goodness-of-fit test for the specified proportions. If you specify null hypothesis frequencies with the TESTF= option, CHISQ computes a chi-square goodness-of-fit test for the specified frequencies.
Main discussion: Chi-Square Tests and Measures
Featured in: Analyzing a 2×2 Contingency Table and Creating an Output Data Set Containing Chi-Square Statistics

CL
requests confidence limits for the MEASURES statistics.
Interaction: If you omit MEASURES, CL invokes MEASURES.
Interaction: PROC FREQ determines the confidence coefficient using ALPHA= , which by default equals 0.05 and produces 95 percent confidence limits.
Main discussion: Measures of Association
Featured in: Computing the Cochran-Armitage Trend Test

CMH
computes Cochran-Mantel-Haenszel statistics, which test for association between the row and column variables after adjusting for the remaining variables in a multiway table. In addition, for 2×2 tables, PROC FREQ computes adjusted Mantel-Haenszel and logit estimates of the odds ratio and relative risks as well as the corresponding confidence limits. For the stratified 2×2 case, PROC FREQ computes the Breslow-Day test for homogeneity of odds ratios.
Interaction: CMH1 and CMH2 control the number of CMH statistics that PROC FREQ computes.
Main discussion: Cochran-Mantel-Haenszel Statistics
Featured in: Computing Cochran-Mantel-Haenszel Statistics for a Stratified Table

CMH1
requests the Cochran-Mantel-Haenszel correlation statistic and, for 2×2 tables, adjusted Mantel-Haenszel and logit estimates of the odds ratio and relative risks as well as the corresponding confidence limits. For the stratified 2×2 case, PROC FREQ computes the Breslow-Day test for homogeneity of odds ratios. Except for 2×2 tables, CMH1 requires less memory than CMH, which can require an enormous amount for large tables.

CMH2
requests the Cochran-Mantel-Haenszel correlation statistic, row mean scores (ANOVA) statistic and, for 2×2 tables, adjusted Mantel-Haenszel and logit estimates of the odds ratio and relative risks as well as the corresponding confidence limits. For the stratified 2×2 case, PROC FREQ computes the Breslow-Day test for homogeneity of odds ratios. Except for tables with two columns, CMH2 requires less memory than CMH, which can require an enormous amount for large tables.
Featured in: Computing Friedman's Chi-Square Statistic

CONVERGE=c
specifies the convergence criterion for computing the polychoric correlation using the PLCORR option. Iterative computation of the polychoric correlation stops when the convergence measure falls below the value of CONVERGE=, or when the number of iterations that is specified by the MAXITER= option is exceeded, whichever happens first.
Alias: CONV=
Default: 0.0001
Range: a positive number
Main discussion: Polychoric Correlation

CUMCOL
displays the cumulative column percentages in cells of the crosstabulation table.

DEVIATION
displays the deviation of the cell frequency from the expected frequency for each cell of the crosstabulation table.
Interaction: DEVIATION is valid for crosstabulation tables but has no effect on tables produced with LIST.
Featured in: Creating an Output Data Set Containing Chi-Square Statistics

EXPECTED
displays the expected cell frequencies under the hypothesis of independence (or homogeneity).
Interaction: EXPECTED is valid for contingency tables but has no effect on tables produced with LIST.
Featured in: Creating an Output Data Set Containing Chi-Square Statistics

FISHER
computes Fisher's exact test even when tables are larger than 2×2. You can also request Fisher's exact test by specifying FISHER in the EXACT statement.
Alias: EXACT
Interaction: If you omit CHISQ, FISHER invokes CHISQ.
Interaction: ALL does not invoke this option.
Main discussion: Fisher's Exact Test
CAUTION:
For large tables, PROC FREQ may require a large amount of time or memory to compute exact p-values. See Computational Resources for more information.  [cautionend]

JT
performs the Jonckheere-Terpstra test.
Main discussion: Jonckheere-Terpstra Test

LIST
displays two-way to n-way tables in a list format rather than as crosstabulation tables.
Restriction: PROC FREQ ignores LIST when you request statistical tests or measures of association.

MAXITER=n
specifies the maximum number of iterations for computing the polychoric correlation using the PLCORR option. Iterative computation of the polychoric correlation stops when the number of iterations that is specified by MAXITER= is exceeded, or when the convergence measure falls below the value of the CONVERGE= option, whichever happens first.
Default: 20
Range: an integer between 0 and 32767
Main discussion: Polychoric Correlation

MEASURES
requests several measures of association and their asymptotic standard errors (ASE). The measures include gamma, Kendall's tau-b, Stuart's tau-c, Somers' D, Pearson and Spearman correlation coefficients, lambda (asymmetric and symmetric), uncertainty coefficients (asymmetric and symmetric) and, for 2×2 tables, the odds ratio, column 1 relative risk, column 2 relative risk, and the corresponding confidence limits.
Interaction: CL requests confidence limits.
Main discussion: Measures of Association
Featured in: Computing the Cochran-Armitage Trend Test

MISSING
treats missing values as nonmissing and includes them in calculations of percentages and other statistics.
Main discussion: Missing Values

MISSPRINT
displays missing value frequencies for all tables, even though PROC FREQ does not use the frequencies in the calculation of statistics.
Main discussion: Missing Values

NOCOL
suppresses the column percentages in cells of the crosstabulation table.
Featured in: Creating an Output Data Set Containing Chi-Square Statistics

NOCUM
suppresses the cumulative frequencies and cumulative percentages for one-way frequency tables and for frequencies in list format.
Featured in: Computing Chi-Square Tests for One-Way Frequency Tables

NOFREQ
suppresses the cell frequencies for a crosstabulation table. This also suppresses frequencies for row totals.

NOPERCENT
suppresses the cell percentages, the row total percentages, and the column total percentages for a crosstabulation table. For one-way frequency tables and frequencies in list format, suppresses the percentages and the cumulative percentages.

NOPRINT
suppresses the frequency and crosstabulation tables, but displays all requested tests and statistics.
Featured in: Computing Cochran-Mantel-Haenszel Statistics for a Stratified Table

NOROW
suppresses the row percentages in cells of the crosstabulation table.
Featured in: Creating an Output Data Set Containing Chi-Square Statistics

OUT=SAS-data-set
names the output data set that contains variable values and frequency counts. The variable COUNT contains the frequencies and the variable PERCENT contains the percentages. If more than one table request appears in the TABLES statement, the contents of the data set correspond to the last table request in the TABLES statement.
Main discussion: Output Data Sets
See also: OUTEXPECT and OUTPCT
Featured in: Creating an Output Data Set with Table Cell Frequencies

OUTEXPECT
includes the expected frequency in the output data set when you specify the OUT= option. The variable EXPECTED contains the expected frequency for each table cell.
Main discussion: Output Data Sets
Featured in: Creating an Output Data Set with Table Cell Frequencies

OUTPCT
includes the following additional variables in the output data set when you specify the OUT= option:

PCT_COL
the percentage of column frequency

PCT_ROW
the percentage of row frequency

PCT_TABL
the percentage of stratum frequency, for n-way tables where n > 2.

Main discussion: Output Data Sets

PLCORR
computes the polychoric correlation coefficient. For 2×2 tables, this statistic is more commonly known as the tetrachoric correlation coefficient, and is labeled as such in the displayed output.
Interaction: If you omit MEASURES, PLCORR invokes MEASURES.
Main discussion: Polychoric Correlation
See also: CONVERGE= and MAXITER=

PRINTKWT
requests that PROC FREQ display the kappa coefficient weights.
Interaction: You must specify AGREE to compute the kappa coefficients. The WT= option controls how PROC FREQ computes the kappa coefficient weights.
Main discussion: Weighted Kappa Coefficient

RELRISK
requests relative risk measures for 2×2 tables. These measures include the odds ratio, column 1 relative risk, and column 2 relative risk.
Main discussion: Odds Ratio and Relative Risks for 2×2 Tables
Featured in: Analyzing a 2×2 Contingency Table

RISKDIFF
requests column 1 and 2 risks (or binomial proportions), risk differences, and their confidence limits for 2×2 tables.
Alias: PDIFF, RDIFF
Main discussion: Risks and Risk Differences

SCORES=type
specifies the type of row and column scores that PROC FREQ uses with the Mantel-Haenszel chi-square, Pearson correlation, Cochran-Armitage test for trend, weighted kappa coefficient, and Cochran-Mantel-Haenszel statistics where type is
MODRIDIT
RANK
RIDIT
TABLE

By default, the row or column scores are the integers 1,2,... for character variables and the actual variable values for numeric variables. Using other types of scores yields nonparametric analyses.
Default: TABLE
Main discussion: Scores
Featured in: Computing Friedman's Chi-Square Statistic

SCOROUT
displays the row and the column scores. You specify the score type with the SCORES= option. PROC FREQ uses the scores when it calculates the Mantel-Haenszel chi-square, Pearson correlation, Cochran-Armitage test for trend, weighted kappa coefficient, or Cochran-Mantel-Haenszel statistics.
Restriction: SCOROUT displays the row and column scores only when statistics are computed for two-way tables.
Tip: To store the scores in an output data set, use the Output Delivery System.
Main discussion: Scores
See also: SCORES=

SPARSE
lists all possible combinations of the variable values for an n-way table when n>1 even if a combination does not occur in the data. SPARSE has no effect unless you use the LIST or OUT= option. When you use SPARSE and LIST, PROC FREQ lists any combination of values with a frequency count of zero. When you use SPARSE and OUT= , PROC FREQ includes empty crosstabulation table cells in the output data set.
See also: Missing Values
Featured in: Creating an Output Data Set with Table Cell Frequencies

TESTF=(values)
specifies the null hypothesis frequencies for a one-way chi-square test for specified frequencies. You can separate values with blanks or commas.
Range: The sum of the frequency values must equal the total frequency for the one-way table.
Restriction: The number of TESTF= values must equal the number of variable levels in the one-way table. List these values in the order that the corresponding variable levels appear in the output.
Interaction: If you omit CHISQ, TESTF= invokes CHISQ.
Main discussion: Chi-Square Test for One-Way Tables

TESTP=(values)
specifies the null hypothesis proportions for a one-way chi-square test for specified proportions. You can separate values with blanks or commas.
Range: Specify values in probability form as numbers between 0 and 1, where the proportions sum to 1. Or, specify values in percentage form as numbers between 0 and 100, where the percentages sum to 100.
Restriction: The number of TESTP= values must equal the number of variable levels in the one-way table. List these values in the order that the corresponding variable levels appear in the output.
Interaction: If you omit CHISQ, TESTP= invokes CHISQ.
Main discussion: Chi-Square Test for One-Way Tables
Featured in: Computing Chi-Square Tests for One-Way Frequency Tables

TOTPCT
displays the percentage of total frequency on crosstabulation tables, for n-way tables where n > 2. This percentage is also available with the LIST option or as the PERCENT variable in the OUT= output data set.

TREND
performs the Cochran-Armitage test for trend.
Restriction: The table must be 2×c or r×2.
Main discussion: Cochran-Armitage Test for Trend
Featured in: Computing the Cochran-Armitage Trend Test

V5FMT
uses a field that is 8 positions wide to display the cell frequencies between 1.E7 and 1.E8 so that PROC FREQ does not use scientific notation to display frequencies in this range. By default, PROC FREQ uses a maximum of 7 positions to display cell frequencies. In Version 5 of the SAS System, PROC FREQ used a maximum of 8 positions.


Chapter Contents

Previous

Next

Top of Page

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