Search the site...

SASCRUNCH TRAINING
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
  • Home
  • Member's Area
  • How to Start
  • SAS Interface
  • Creating a Data Set
  • Practical SAS Training Course
  • SAS Certified Specialist Training Program
  • Proc SQL Course
  • Introduction to Time Series Analysis
  • SAS Project Training Course
  • Full Training / Membership
  • Sign up
  • About us
  • Contact us
Sentry Page Protection
Please Wait...
Data Analysis [7-15]


Classification Variable
(Proc Means)
Again, similar to Proc Univariate, you can specify the classification variables using the Class statement.
​
Example
Picture

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;
Picture

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

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;
Picture

This will generate similar results as using the CLASS statement:
Picture

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

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.

Already a member? Go to member's area.