SAS Arithmetic Mean – SAS PROC MEANS Tutorial
Interactive Online Courses: Elevate Skills & Succeed Enroll 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 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.
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;
proc Means Data=SASHelp.cars maxdec=2; Var MSRP Invoice; Run;
Â
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 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;
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.
You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google