Home » SAS-Frequency Distribution

SAS-Frequency Distribution

by Online Tutorials Library

SAS-Frequency Distribution

SAS frequency distribution is the most commonly used statistical procedure in SAS programming.

Descriptive statistics such as mean and standard deviation can be used for continuous variables to summarize the data, but in the case of Categorical variables, Descriptive statistic is not appropriate.

We can summarize Categorical variables by using a frequency table, but Before proceeding, let’s first understand the categorical variable.

Categorical Variable:

Purely Categorical variables are those that allow us to assign categories, but not let to arrange them in a particular sequence. In other words, a Categorical variable is one which has two or more categories, but there is no sequence of these categories.

For example, gender is a Categorical variable, which holds two categories i.e., male and female, but there is no sequence of both categories. Another example is hair color, which is also considered as a Categorical variable as it holds several categories, i.e., black, brown, brunette, red, etc. again, there is no sequence in which we can arrange it.

Frequency Table:

Frequency table displays the number and percentage of cases observed for each category of a variable.

Each entry in the frequency table contains the count of the occurrences of values in a particular interval.

Now, let’s discover how we can implement frequency distribution operations in SAS programming language.

PROC FREQ

We can calculate the frequency distribution of observations of a variable by using the PROC FREQ procedure.

Syntax:

Where,

  • Dataset: It is the name of the dataset that will be used for frequency distribution.
  • Variables1: It is the name of the variable whose frequency distribution needs to be calculated.
  • Variables2: It is the variable declared to categorize the frequency distribution result.

Use of SAS PROC FREQ

The primary purpose of PROC FREQ is that we can calculate the frequency of any user-defined or already available or SAS in-built help library data set. In order to calculate the frequency distribution, we only need to specify the name of the dataset.

Example

Execute the following code in SAS Studio:

SAS-Frequency Distribution

Output:

SAS-Frequency Distribution

Single Variable Frequency Distribution

Frequency distribution of a single variable can be determined by using the PROC FREQ procedure. After implementing the PROC FREQ procedure, the result will show the frequency of each contained observation of the variable. It will also show the percentage distribution, cumulative frequency, and cumulative percentage.

Example:

In this example, we are going to calculate the frequency distribution of variable “horsepower” for the dataset CARS1, which is created from already available data set CARS of SAS help Library.

Execute the following code in SAS Studio:

SAS-Frequency Distribution

Output:

SAS-Frequency Distribution

Multiple Variable Frequency Distribution

Frequency distribution of multiple variables can be determined by using the PROC FREQ procedure. After implementing the PROC FREQ procedure, the result will show the frequency of each contained observation of all variables. It will also show the percentage distribution, cumulative frequency, and cumulative percentage for all variables. Let’s understand the implementation of this process through an example.

Example:

In this example, we are going to calculate the frequency distribution of two variables, the first variable is make, and another is type. Both variables belong to the dataset CARS1, which is created from already available data set CARS of SAS help Library.

Execute the following code in SAS Studio:

SAS-Frequency Distribution

Output:

SAS-Frequency Distribution

Frequency Distribution with Weight

In the frequency distribution, Weight option is used to calculate the biased frequency distribution with the weight of the variable.

Example

In the below example, we are going to calculate the frequency distribution of the variable make and type with the weight assigned in horsepower. Let’s understand through the code:

When we execute the above code in SAS Studio, we will get the following output:

SAS-Frequency Distribution
SAS-Frequency Distribution


You may also like