SAS Frequency Distribution
SAS Frequency Distribution

SAS Frequency Distribution

SAS Frequency Distribution

For continuous variables, descriptive statistics like mean and standard deviation can be used to summarize the data. But for categorical variables, these measures are not appropriate. Categorical variables can be summarized using a frequency table, which shows the number and percentage of cases observed for each category of a variable.

Let’s Read SAS Cross Tabulation in detail

A categorical variable (sometimes called a nominal variable) is one that has two or more categories, but there is no ordering to the categories. For example, gender is a categorical variable having two categories (male and female) and there is no ordering to the categories. Hair color is also a categorical variable having a number of categories (blonde, brown, brunette, red, etc.) and again, there is no agreed way to order these from highest to lowest. A purely categorical variable is one that simply allows you to assign categories but you cannot clearly order the variables.

SAS frequency distribution table looks like the one shown below-

Example SAS Frequency Distribution

SAS PROC FREQ Procedure

The SAS PROC FREQ procedure prints all values of a given categorical variable in the Output window, along with the number and percentage of times each value appears. The FREQ procedure can work with both string (character) or numeric categorical variables.

The syntax of SAS PROC FREQ statement is:

  1. PROC FREQ DATA = Dataset ;
  2. TABLES Variable1 ;
  3. BY Variable2 ;

The PROC FREQ statement is the only required statement for the FREQ procedure.

A basic frequency table created with PROC FREQ will have the following properties:

  • It will include the frequency, percentage, cumulative frequency, and cumulative percent for each category.
  • If there are cases with missing values for the variable, the number of missing values are given below the table.
  • For string variables, the categories will be ordered alphabetically. For numeric variables, the categories will be ordered from smallest to the largest indicator.

Basic Usage of SAS PROC FREQ

This is the most basic form of a PROC FREQ in SAS Frequency Distribution. We only need to specify the name of the dataset and not the variables.

Example-

  1. Proc freq data=SASHelp.cars;
  2. Run;

The code above creates a frequency table for each of the variable in the dataset.

For example, below is a frequency table for the variable MAKE.

SAS PROC FREQ with tables option ( single variable)

Using SAS Proc Freq without any options is usually not recommends, particularly if you have a large dataset which contains variables that have many unique values (levels). Tables statement use in such cases.

Read about SAS Proc Sort Data Sets in detail

Example-

  1. Proc freq data=SASHelp.cars ;
  2. Tables Origin;
  3. Run;

SAS PROC FREQ – Single Variable

b. Multiple variable frequency distributions

Many numbers of tables can be generated for as many variables that are present in the dataset.

Example-

  1. PROC FREQ DATA=sample;
  2. TABLE State Rank;
  3. RUN;

Read Complete Article>>


要查看或添加评论,请登录

Malini Shukla的更多文章

社区洞察

其他会员也浏览了