Frequency Tables in SAS

Overview

Frequency tables are an excellent way to check the validity of your data. Do the values you find for a variable fall within the range of possibility. If not, then some form of measurement error or coding error has occurred. For variables that use nominal or ordinal data frequency tables are one of the key methods of analysis. SAS provides two procedures for performing frequency tables, proc univariate and proc freq.

Procedure Freq

Proc freq will produce a frequency table for each variable you list. The basic format of this procedure is:

proc freq data=dataset;
tables variable-list;
run;

If you do not specify the tables keyword then all variables will be done. This can (often does!) produce a large amount of output. For a large number of cases using proc freq on interval or ratio variables may not be the best approach to take and you should consider using proc univariate.

Example 2. Using Proc Freq

Procedure Univariate

Proc univariate will produce a frequency table if directed to by specifying the freq keyword in the procedure declaration. Proc univariate will not analzye variables defined to be of type character in the input keyword and is limited to numeric values only. In addition, proc univariate will generate a page with assorted statistics for each variable specified.

The statistics generated by proc univariate fall into three categories, moments which provide statistics such as mean, variance, etc.; quantiles which show the distribution of the values; and extremes which highlight the highest and lowest observed values. The extremes output is very helpful in identifying errors in your data for interval or ratio variables.

The following code show the basic setup:

proc univariate data=dataset freq;
var variable-list;
run;

Using Proc Univariate with Freq Keyword


Back to Sas Index Page

Author - Jack Suess
UMBC University Computing Services
Created - 1/15/96