SAS Arithmetic Mean – SAS PROC MEANS Tutorial

FREE Online Courses: Click, Learn, Succeed, Start Now!

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 .

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

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

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

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

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

SAS Arithmetic Mean of Specific Variables – Example

 

SAS Arithmetic Mean

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

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.

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.

Did you like this article? If Yes, please give DataFlair 5 Stars on Google

follow dataflair on YouTube

Leave a Reply

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