# SAS Arithmetic Mean – SAS PROC MEANS Tutorial

Job-ready Online Courses: Knowledge Awaits â€“ Click to Access!

Till now we have looked at how to represent data and different operations that can be applied to the dataset.

Now onwards, we will discuss the different statistical procedures that can be applied to our dataset beginning from SAS arithmetic mean with SAS PROC MEANS. We also see some SAS PROC MEANS examples.

## What is SAS Arithmetic Mean

SAS arithmetic mean is the sum of values of a numeric variable in a dataset divided by the total number of observations.

SAS Arithmetic mean Example

## SAS PROC MEANS Procedure

We used SAS PROC MEANS to find arithmetic mean of our data. PROC MEANSÂ produces descriptive statistics (means, standard deviation, minimum, maximum, etc.) for numeric variables in a set of data.

SAS PROC MEANS syntaxÂ is:

`PROC MEANS <options>; <statements>;`

Statistical options that may be requested are: (default statistics are underlined.)

• NÂ – Number of observations
• NMISS – Number of missing observations
• MEANÂ – Arithmetic average)
• STDÂ –Â  Standard Deviation
• MINÂ –Â  Minimum (smallest)
• MAXÂ –Â  Maximum (largest)
• RANGE – Range
• SUM –Â  Sum of observations
• VAR –Â  Variance

Other commonly usedÂ optionsÂ available in SAS PROC MEANS include:

• DATA=Â Specify dataset to use
• NOPRINTÂ Do not print output
• MAXDEC=nÂ Use n decimal places to print output

Commonly usedÂ statementsÂ with SAS PROC MEANS include:

• BY variable listÂ — Statistics are reported for groups in separate tables
• CLASS variable listÂ â€“ Statistics reported by groups in a single table
• VAR variable listÂ â€“ specifies which numeric variables to use
• OUTPUT OUT = dataset nameÂ â€“ statistics will be output to a SAS data file
• FREQ variable –Â specifies a variable that represents a count of observations

## SAS Arithmetic Mean of an Entire Dataset

This is the most basic form of a SAS PROC MEANS. We only need to specify the name of the dataset and not the variables.
Example-

```Proc Means Data=SASHelp.cars;
Run;```

The basic form of SAS PROC MEANSÂ computes a set of descriptive statistics. The descriptive statistics are computed for all the numeric variables in the dataset.

SAS PROC MEANS Example

By default, the statistics N, Mean, Standard Deviation, Minimum and Maximum are computed.

a. Display Different Decimal Places
You can also specify the number of decimal places you want to display using the MAXDEC= option.

Example-

```Proc Means Data=SASHelp.carsÂ maxdec=0;
Var MSRP Invoice;
Run;```

SAS Arithmetic Mean – Display Decimal Places

```proc Means Data=SASHelp.carsÂ maxdec=2;
Var MSRP Invoice;
Run;```

Â

SAS Arithmetic Mean – Display 2 Decimal Places

## SAS Arithmetic Mean of Specific Variables

Sometimes you might be interested in only a few selected variables for your analysis. You can add the VAR statement to limit the analysis to only the variables you are interested in.

The VAR statement below limits the analysis to only the MSRP and INVOICE variables.Â No results are computed for any other variables in the dataset.

Example-

```Proc Means Data=SASHelp.cars;
Var MSRP Invoice;
Run;```

SAS Arithmetic Mean of Specific Variables – Example

SAS Arithmetic Mean of Specific Variables – Output

## SAS Arithmetic Mean by Class

Every variable is different in some aspect, like in the cars dataset, the price of a Porsche is likely to be very different from that of a Toyota. Thus, it makes more sense to separate the analysis for each car maker. A CLASS statement can be added to theÂ MEANS procedure to group your analysis.

In the below example, By specifying the variable MAKE as the classification variable, there will be a separate analysis completed for each car maker.

Example-

```Proc Means Data=SASHelp.cars;Class Make;
Var MSRP Invoice;
Run;```

SAS Arithmetic Mean by CLASS – Example

SAS Arithmetic Mean by CLASS – Result

This was all about SAS Arithematic Mean Tutorial. Hope you like our explanation on SAS PROC MEANS.

## Conclusion

Hence, we hope you all understood how we can use SAS PROC MEANS procedure to find SAS arithmetic mean of our dataset, how can we specify only the variables that we want.

Also, the use of CLASS statement for better analysis of our data. We will learn more interesting statistical procedures in the coming tutorials. For any queries post your doubts in the comments section below.

Your 15 seconds will encourage us to work even harder