May 27, 2021 SAS
2. Single variable frequency distribution
4. Multivarivation frequency distribution
The frequency distribution is a table that shows the frequency of the data points in the data set. Each entry in the table contains the frequency or count of values within a specific group or interval, and in this way, the table summarizes the distribution of values in the sample.
SAS provides a process called PROC FREQ to calculate the frequency distribution of data points in the data set.
The basic syntax for calculating frequency distribution in SAS is:
PROC FREQ DATA = Dataset ; TABLES Variable_1 ; BY Variable_2 ;
The following is a description of the parameters used:
We can use PROC FREQ to determine the frequency distribution of individual variables. I n this case, the result shows the frequency of each value of the variable. T he results also show the percentage distribution, cumulative frequency, and cumulative percentage.
In the following example, we find the frequency distribution of the variable horsepower of a dataset called CARS1, created from the library SASHELP.CARS. W e can see that the results fall into two categories. O ne for every car.
PROC SQL; create table CARS1 as SELECT make,model,type,invoice,horsepower,length,weight FROM SASHELP.CARS WHERE make in ('Audi','BMW') ; RUN; proc FREQ data=CARS1 ; tables horsepower; by make; run;
When we execute the code above, we get the following results:
We can find the frequency distribution of multiple variables and compose them into all possible combinations.
In the following example, we calculate the frequency distribution of automobile manufacturing grouped by car type and the frequency distribution of each type of car grouped by each manufacturing group.
proc FREQ data=CARS1 ; tables make type; run;
When we execute the code above, we get the following results:
Using the weight option, we can calculate the frequency distribution that is biased by the weight of the variable. H ere, the value of the variable is taken as the number of observations, not the count of the values.
In the following example, we calculate the frequency distribution of the variables make and type, assigned to the weight of horsepower.
proc FREQ data=CARS1 ; tables make type; weight horsepower; run;
When we execute the code above, we get the following results: