Contributor
Posts: 53

# Proc means weight option - explain SAS Help example

Hi,

In SAS 9.2 Help, there is an example entitled "Weighted Statistics Example" that uses the Proc Means Weight option. I am trying to understand how the variances in the example are calculated by doing it manually in EXCEL, but I cannot work out how SAS calculates it. Referring to the code below, I am able to calculate the variance that is in Example 1, but can someone please explain to me Example 2 and 3.

My exact questions are:

1. In example 2, how do you calculate Est_SigmaSq (i.e. var)?

2. If you were to transform the variable ObjectSize in Example 2, what would it be in order to get the variance Est_SigmaSq?

3. The same two questions apply for Example 3.

Below is the code as given in SAS Help and I also attach the Excel I am using to do my manual calculations if you need it.

Thanks and Regards

Ian.

data size;

input Distance ObjectSize @@;

Precision=1/distance;

datalines;

1.5 30 1.5 20 1.5 30 1.5 25

3   43 3   33 3   25 3   30

4.5 25 4.5 36 4.5 48 4.5 33

6   43 6   36 6   23 6   48

7.5 30 7.5 25 7.5 50 7.5 38

;

*EXAMPLE1;

proc means data=size maxdec=3 n mean var stddev;

var objectsize;

title1 'Unweighted Analysis of the SIZE Data Set';

run;

**EXAMPLE2;

proc means data=size maxdec=3 n mean var stddev;

weight precision;

var objectsize;

output out=wtstats var=Est_SigmaSq std=Est_Sigma;

title1 'Weighted Analysis Using Default VARDEF=DF';

run;

**EXAMPLE3;

proc means data=size maxdec=3 n mean var std vardef=weight;

weight precision;

var objectsize;

title1 'Weighted Analysis Using VARDEF=WEIGHT';

run;

Regular Contributor
Posts: 152

## Re: Proc means weight option - explain SAS Help example

The documentation for the WEIGHT statement in PROC MEANS.describes how the sample variance is calculated from the individual variable values and their weights, the weighted mean, and the divisor[the default value of n-1 or of the sum of the weights when VARDEF=WEIGHT].

Contributor
Posts: 53

## Re: Proc means weight option - explain SAS Help example

1zmm, thanks for answering, but I have read the documentation that you refer to (a number of times) and it does not answer my question. That is why I am asking if someone can help me here.

Ian.

Super User
Posts: 20,770

## Re: Proc means weight option - explain SAS Help example

If you want to mimic the calculation in Excel, take the weight and multiply it by the observation, precision*object_size

Then calculate STD and Variance as you would normally in excel using the weighted observations.

Contributor
Posts: 53

## Re: Proc means weight option - explain SAS Help example

Ok. Thanks. I have been able to reproduce the results.

Discussion stats
• 4 replies
• 388 views
• 0 likes
• 3 in conversation