Demand Planning.net
About Us | Questions and Answers | Resources | Job Postings | Comments | Contact Us

Forecasting Links:

Time Series
Exception Analysis
Causal Modeling
SAS Techniques
Forecast Reconciliation

Contact

Demand Planning, LLC
Post Office Box 261
Lexington, MA 02420

617.297.2385

 

SAS Techniques - Random Notes on SAS challenges and solutions

    Creating Weighted Statistics in SAS 
    Mark C  Feb 20, 2004

I wanted to Proc means to calculate weighted statistics but the options seem too involved. In the specific example, you have hundred days that are zero and the remaining days have positive values where some of the zeros are not coded as zeros but simply the date is omitted. What is the average daily value?

If you computed an unweighted simple average, it will be misleading. It will overstate the mean since it will not weight the zeros. So the observed average needs to be multiplied by a proportion of number of non-zero days over total number of days. However the variance cannot be easily adjusted.

So in SAS, I created a row of zero and weighted it with 365-number of non zero rows. I created a weight of 1 for every non-zero row. If you use proc means and apply weighting option you are done. The mean is easy......... but the variance needs more work. You need to specify a variance deflator option to indicate you really want to use the total of weights to arrive at the variance.

This option is VARDEF=WEIGHT. See the example

weighted mean and variances using VARDEF option
 

Home | Planning | Metrics | POS Analysis | Forecasting | Workshops | Services
About Us | Questions | Resources | Jobs | Comments | Contact Us!

© 2004 by by Mark Chockalingam. All rights reserved. Privacy policy.