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 that
has continuous numeric valuessuch as To specify the variables to be processed by the FREQ procedure, include a TABLES statement. |
General form, TABLES statement:
where |
Example
The order in which the variables appear in the TABLES statement determines the order in which they are listed in the PROC FREQ report. Consider the SAS data set Finance.Loans. The variables
|
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 |