SAS Arithmetic Mean – SAS PROC MEANS Tutorial

1. Objective

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.

So, let’s start with SAS Arithmetic Mean .

SAS Arithmetic mean

SAS Arithmetic mean

2. 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.

Read about Syntax of SAS Programming in detail

SAS Arithmetic mean

SAS Arithmetic mean Example

3. 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.

First of all, revise SAS Dataset in detail

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

Read about SAS Variables in detail

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

4. 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 Arithmetic Mean

SAS PROC MEANS Example

Let’s look at SAS Numeric Format – SAS Informat & Output Format

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

SAS Arithmetic Mean – Display Decimal Places

 

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

 

SAS Arithmetic Mean

SAS Arithmetic Mean – Display 2 Decimal Places

5. 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.

Do You Know How to Enter and Read Raw Data in SAS

Example-

Proc Means Data=SASHelp.cars;
Var MSRP Invoice;
Run;
SAS Arithmetic Mean

SAS Arithmetic Mean of Specific Variables – Example

 

SAS Arithmetic Mean

SAS Arithmetic Mean of Specific Variables – Output

 

6. 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.

Let’s discuss SAS Histogram Statement With UNIVARIATE Procedure

Example-

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

 

SAS Arithmetic mean

SAS Arithmetic Mean by CLASS – Example

 

SAS Arithmetic mean

SAS Arithmetic Mean by CLASS – Result

 

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

7. 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.

Related Topic – SAS Pie Chart 

For reference

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.