SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Computing Frequency Distributions
Lesson Summary

This page contains


I. Text Summary

To go to the page where a task, programming feature, or concept was presented, select a link.


Introduction
The FREQ procedure reports the distribution of variable values, both as percentages of a total and as counts of data. Output can appear as lists or as crosstabulations in two-way and n-way tables.

Procedure Syntax
By default, PROC FREQ lists the frequency, percentage, cumulative frequency, and cumulative percentage of every variable (both character and numeric) in the data set.

Selecting Variables
To specify the variables to analyze, include them in a TABLES statement. Variables with repeating values are the best choices for frequency tables.

Specifying Frequency Order
Normally, the FREQ procedure prints frequencies by the order of internal values for each variable. To specify the order of the variable levels, include the ORDER= option:

  • ORDER=DATA orders values by appearance in the data set
  • ORDER=FORMATTED orders by formatted value
  • ORDER=FREQ orders values by descending frequency count
  • ORDER=INTERNAL orders by unformatted value (default)

Two-Way Tables
When a TABLES statement contains two variables joined by an asterisk (*), PROC FREQ produces crosstabulations. The resulting table displays values for:

  • cell frequency
  • cell percentage of total frequency
  • cell percentage of row frequency
  • cell percentage of column frequency

N-Way Tables
Crosstabulations can include more than two variables. When three or more variables are joined in a TABLES statement, the result is a series of two-way tables that are grouped by the values of the first variables listed.

List Output
To reduce the bulk of n-way table output, add a slash (/) and the LIST option to the end of the TABLES statement. PROC FREQ will print compact, multi-column lists instead of a series of tables.

Suppressing Table Information
You can suppress the display of specific statistics by adding one or more options to the TABLES statement:

  • NOFREQ suppresses cell frequencies
  • NOPERCENT suppresses cell percentages
  • NOROW suppresses row percentages
  • NOCOL suppresses column percentages


II. Syntax

To go to the page where a statement or option was presented, select a link.

PROC FREQ <DATA=SAS-data-set>
<ORDER=DATA|FREQ|INTERNAL|FORMATTED>;
TABLES variable-1*variable-2 <* ... variable-n>
/ <NOFREQ|NOPERCENT|NOROW|NOCOL> <LIST>;
RUN;


III. Sample Program

     proc freq data=clinic.heart order=freq;
        tables sex*survive*shock / nopercent list;
     run;


IV. Points to Remember
  • Without a TABLES statement, PROC FREQ will produce statistics for every variable in the data set.

  • Variables with continuous numeric values can create a large amount of output. Use a TABLES statement to exclude such variables, or group their values by applying a FORMAT statement.


  back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement