turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Proc means weight option - explain SAS Help exampl...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-25-2013 08:10 AM

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-25-2013 08:47 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-25-2013 09:33 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-25-2013 10:47 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-27-2013 05:39 AM

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