May 27, 2021 SAS
Arithmetic averages are values obtained by mething the values of numeric variables and then divideing the values by the number of variables. I t is also known as the mean. T he SAS arithmetic average is calculated using PROC MEANS. U sing this SAS program, we can find the average of all variables or some variables of the dataset. W e can also form groups and find the average value of variables that are specific to the values of that group.
The basic syntax for calculating arithmetic averages in SAS is:
PROC MEANS DATA = DATASET; CLASS Variables ; VAR Variables;
The following is a description of the parameters used:
The average value of each numeric variable in the dataset is calculated by using proC to provide only the dataset name without using any variables.
In the following example, we find the average of all the numeric variables in the SAS data set called CARS. W e specify the maximum number of digits after the scale to 2 and find the sum of these variables.
PROC MEANS DATA = sashelp.CARS Mean SUM MAXDEC=2; RUN;
We can get the average of some variables by providing their names in the var option.
Below, we calculate the average of the three variables.
PROC MEANS DATA = sashelp.CARS mean SUM MAXDEC=2 ; var horsepower invoice EngineSize; RUN;
When we execute the above code, we get the following output:
We can find the average of numeric variables by using some other variables to aggregate them into groups.
In the following example, we find the average of each type of variable horsepower under each model.
PROC MEANS DATA = sashelp.CARS mean SUM MAXDEC=2; class make type; var horsepower; RUN;
When we execute the above code, we get the following output: