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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s