Sentry Page Protection
Data Analysis [7-15]
Classification Variable
(Proc Means)
Again, similar to Proc Univariate, you can specify the classification variables using the Class statement.
Example
Example
The COTTON data set contains the listed price of cotton from 20 different companies on Alibaba.com.
Of the 20 companies listed, 10 are from China and the other 10 are from Pakistan.
Let's take a look at how you can analyze the cotton price from the two countries.
Example
Proc Means Data=Cotton;
Var Price;
Class Origin;
Run;
The CLASS statement is added to Proc Means specifying the variable Origin as the classification variable.
The analysis will be separated for the two origins.
BY Statement
You can also use the BY statement to separate the analysis into different groups.
Example
Proc Sort Data=Cotton;
By Origin;
Run;
Proc Means Data=Cotton;
Var Price;
By Origin;
Run;
This will generate similar results as using the CLASS statement:
Note: the Class statement is generally preferred, as it does not require data set to be sorted prior to running the procedure.
Exercise
Compute the range, Q1, median and Q3 statistics on the cotton prices between the two origins.
Compute the range, Q1, median and Q3 statistics on the cotton prices between the two origins.
Need some help?
HINT:
Either the Class statement or By statement works.
SOLUTION:
Proc Means Data=Cotton Range Q1 Median Q3;
Var Price;
Class Origin;
Run;
Fill out my online form.