SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Computing Frequency Distributions
Producing Frequency Tables


Selecting Variables

By default, the FREQ procedure creates frequency tables for every variable in your data set. But this isn't always what you want. A variable with continuous numeric values—such as DateTime—can result in a lengthy and meaningless table. Likewise, a variable with a unique value for each observation—such as FullName—is unsuitable for PROC FREQ processing. Frequency distributions work best with variables that contain repeating values.

To specify variables in the FREQ procedure, include a TABLES statement.


General form, TABLES statement:
TABLES variable(s);

where variable(s) lists the variables to include.


Example

Consider the SAS data set Finance.Loans. The variables Rate and Months have repeating values, so these are the best choices for frequency tables.


SAS Data Set Finance.Loans
Account Amount Rate Months Payment
101-1092
$22,000
10.00%
60
$467.43
101-1731
$114,000
9.50%
360
$958.57
101-1289
$10,000
10.50%
36
$325.02
101-3144
$3,500
10.50%
12
$308.52
103-1135
$8,700
10.50%
24
$403.47
103-1994
$18,500
10.00%
60
$393.07
103-2335
$5,000
10.50%
48
$128.02
103-3864
$87,500
9.50%
360
$735.75
103-3891
$30,000
9.75%
360
$257.75


     proc freq data=finance.loans;
        tables rate months;
     run;

Rate Frequency Percent Cumulative
Frequency
Cumulative
Percent
9.50% 2 22.22 2 22.22
9.75% 1 11.11 3 33.33
10.00% 2 22.22 5 55.56
10.50% 4 44.44 9 100.00

Months Frequency Percent Cumulative
Frequency
Cumulative
Percent
12 1 11.11 1 11.11
24 1 11.11 2 22.22
36 1 11.11 3 33.33
48 1 11.11 4 44.44
60 2 22.22 6 66.67
360 3 33.33 9 100.00


In addition to listing variables separately, you can use a numbered range of variables.
     proc freq data=perm.survey;
        tables item1-item3;
     run;

Item1 Frequency Percent Cumulative
Frequency
Cumulative
Percent
2 1 25.00 1 25.00
4 2 50.00 3 75.00
5 1 25.00 4 100.00

Item2 Frequency Percent Cumulative
Frequency
Cumulative
Percent
1 1 25.00 1 25.00
3 2 50.00 3 75.00
5 1 25.00 4 100.00

Item3 Frequency Percent Cumulative
Frequency
Cumulative
Percent
4 3 75.00 3 75.00
5 1 25.00 4 100.00



  back||next


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

Terms of Use & Legal Information | Privacy Statement