SAS Programming: Summarizing Categorical Data with “Proc Freq”

The freq procedure summarizes categorical data.

Typically one wants to restrict the variables that appear in the proc freq to categorical data by using the “table” command.

In addition to listing variables separately on can used a numbered range of variables to summarize data.

In addition to single variable frequency tables SAS also generates two way tables to compare two values.  The following program formats data and then creates a frequency table for two variables.

Notice how in the output there is a legend box contains information about the fields within the table.

One can also create n-way tables that table more than two variables.  The following code creates two two-way tables by gender by using the command “tables sex*weight*height;” command.

One way to make the data more manageable is to use the list option.  This produces list that are more compact and may be more clear.

One can also limit the way the output looks by specifying the “crosslist” option

The output for only the female sex is shown here:

Finally, tables can be cleaned up by  restricting some of the table information with options like “nofreq”, “nopercent”, “nocol” or “norow”.  The following code only displays the percentage by restricting all other output.