Sentry Page Protection
Data Analysis [11-15]
Proc Freq
Proc Freq is another commonly used statistical procedures in SAS.
It computes the counting statistics on categorical variables.
Example
The BULBS data set contains a list of light bulbs sold at a convenience store.
There are three types of light bulbs:
- Halogen
- Incandescent
- LED
We can count the number of light bulbs of each type using Proc Freq.
Example
Proc Freq Data=Bulbs;
Table Type;
Run;
TABLE Statement
The TABLE statement tells SAS to count how many times each type of light bulbs appear in the data set (i.e. frequency statistics).
The results are shown in a 1-way frequency table below:
The halogen light bulb appears 2 times in the data set while the incandescent and LED light bulbs appear 4 and 6 times, respectively.
The procedure correctly computed the frequency statistics for each type of light bulbs.
In addition to the frequency statistics, Proc Freq also computes:
- the percentage
- the cumulative frequency
- the cumulative percentage
Frequency/Counting statistics offer great insights about the distribution of the data.
You will learn a few more examples later in this module.
Exercise
Copy and run the GUMSALES data set on SAS Studio:
Copy and run the GUMSALES data set on SAS Studio:
The GUMSALES data set contains a list of transactions for the 3 brands of gum.
It contains 3 variables:
- ReceiptID: the receipt number for the transaction
- Brand: the brand of the gum
- Price: the price of the gum
Count how many times each brand of gum is being sold.
Need some help?
HINT:
Make sure you use the TABLE statement in Proc Freq.
SOLUTION:
Proc Freq Data=Gumsales;
Table Brand;
Run;
Fill out my online form.