Frequency procedure

The FREQ procedure tabulates data and gives the frequency of each unique value of the given variable. It can also cross-tabulate, giving the frequency distribution of two or more variables.

In addition to simple tabulation, PROC FREQ can calculate many different statistics (percentages, Pearson and Spearman correlation coefficient, odds ratios, relative risk, ...) and perform several tests (Fisher's exact test (or a MC estimate), Chi-square test, McNemar's test, Mantel-Haenszel test, binomial proportion, ...).

Syntax

PROC FREQ < options >;
  BY byvar(s);
  TABLES request(s) < / options > ;
  EXACT statistic-keyword(s) < / options > ;
  TEST statistic-keyword(s) ;
  WEIGHT variable;
  OUTPUT statistic-keyword(s) < OUT=dataset >;

RUN;
Options on PROC FREQ statement

DATA= : specify input dataset.

COMPRESS : allow for tables to break across pages, in order to conserve space.

NOPRINT : supress displayed output.

ORDER= : specify the order to list the variable values (DATA, FORMATTED, FREQ, INTERNAL).

PAGE : display one table per page.

Statements

BY : separate tables for each Bygroup.

TABLES request(s): request specific frequency or cross-tabulation tables.

Examples of table requests:
TABLES a b c;		A oneway frequency table for each variable: a, b and c.
TABLES a--c; 		A oneway freq table for each variable between a & c.
TABLES a*b; 		A cross-tab table for a X b.
TABLES a*(b c);		A cross-tab table for a X b and a X c.
TABLES a*b*c;		A cross-tab table for a X b X c.
TABLES (a*b) * (c d);	A cross-tab table for a X b X c and a X b X d.

TABLES / options: Specify which tests to perform on tables.

EXACT* : Request exact tests (or MC approximations) for tests.

TEST* : Request tests.

WEIGHT : Specify the variable containing the weight or frequency for the observation.

OUTPUT : Create a SAS dataset containing some available statistics.

*Note: The EXACT and TEST statements have some requirements of the TABLES statement. See the SAS® documentation for more details.

Statistical keywords: AGREE, BINOMIAL, CHISQ, FISHER, JT, KAPPA, LRCHI, MCNEM, MEASURES, MHCHI, OR, PCHI, PCORR, SCORR, TREND, WTKAP