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 [13-15]


WEIGHT Statement
The WEIGHT statement allows you to take into account the weight when computing the frequency statistics.

Example
Picture

The FOOD data set contains a list of 20 transactions.

Three products are sold:
  • ​Chips
  • Pops
  • Ham

The data set also includes the quantity sold for each product in each transaction (QTY).

We are interested in counting the total number of item sold for each product.

In order to take into account the quantity sold for each transaction, we will have to add the WEIGHT statement to Proc Freq.

Example

Proc Freq Data=FOOD;
Table Product;

Weight Qty;
Run;
Picture

The WEIGHT statement takes into account the quantity sold when computing the frequency statistics:
Picture

Let's take a look at the total number of chips sold:
Picture

The number total of chips sold are 1+2+4+1+2+1+1 = 12.

Proc Freq compute the correct total in the Results window:
Picture

Exercise

Copy and run the LIBRARY data set from the yellow box below:

The LIBRARY data set contains a list of books from the library:
  • SAS For Dummies
  • SAS Base Prep Guide
  • SASCrunch Training

The books are distributed across 3 different library location:
  • Markham
  • Toronto
  • North York

The variable N represents the number of copies each library has at their location.

Compute the total number of copies for each book.
Next

Need some help? 


HINT:
The number of copies in each library (i.e. N) should be used as the weight factor.


SOLUTION:
Proc Freq Data=Library;
Table Book;
Weight N;
Run;


Fill out my online form.

Already a member? Go to member's area.