Sentry Page Protection
Proc Means [3-3]
SAS Base Exam
SAS Base Exam
Class Statement
The Class statement allows you to group the data for your analysis.
Example
Copy and run the WINE data set from the yellow box below.
Example
Copy and run the WINE data set from the yellow box below.
A brand of wine was being rated by a group of 15 critics. The results are captured in the WINE data set.
The WINE data set contains the following data:
- ID: Critics ID
- GENDER: the gender of the critics
- AGE: the age of the critics
- RATING: the rating of the wine
Let's run the MEANS procedure on the RATING variable.
By default, the MEANS procedure computes the statistics across the entire column.
Example
Proc Means Data=Wine;
Var Rating;
Run;
Var Rating;
Run;
The MEANS procedure computes the statistics across all of the 15 observations.
What if you want to look at the statistics by the two genders?
Simply add the CLASS statement and specify GENDER as the classification variable.
Example
Proc Means Data=Wine;
Var Rating;
Class Gender;
Run;
The CLASS statement is added to the MEANS procedure.
The analysis is now separated by the two genders.
Output Statement
By default, the analysis results are displayed on the Results window (for SAS Studio).
More often than not, you might want to save the results in an actual data set for further analysis.
This can be done by using the Output statement.
Example
Proc Means Data=Wine;
Var Rating;
Class Gender;
Output out = Stat;
Run;
The Output statement creates an output data set called STAT that can be located in the WORK library.
The STAT data set contains the analysis results from Proc Means.
Exercise
Compute the mean and standard deviation of the wine rating by the gender and age group. Display the statistics in 2 decimal places.
Need some help?
Fill out my online form.