```Date: Thu, 19 May 2011 08:34:29 -0500 Reply-To: Robin R High Sender: "SAS(r) Discussion" From: Robin R High Subject: Re: PROC MEANS/WEIGHTS - any way to output normalised weight values? Comments: To: Arthur Tabachneck In-Reply-To: Content-Type: text/plain; charset="US-ASCII" Art, I attempting to point out that one cannot obtain the unique individual weights that would be in the data file in the presence of repeated values -- I don't deny you would get the same answer for the weighted mean (even std dev); as long as the two (or more) numbers add to the overall weight for the repeated values, there are infinitely many vectors of weights that would work. Note that in the example data the two weights in each column for wn1 wn2 and wn3 for the repeated value of 7.6 all sum to .32353, yet the individual components of that sum are different. If you have several repeated values, the vector of individual weights can look very different, even though they produce the same results. data tst; input wn1 wn2 wn3 value; cards; 0.19853 0.19853 0.19853 10.8 0.15686 0.15686 0.15686 10.3 0.20343 0.12343 0.06343 7.6 0.18627 0.18627 0.18627 1.5 0.13481 0.13481 0.13481 10.0 0.12010 0.20010 0.26010 7.6 ; Robin High UNMC From: Arthur Tabachneck To: SAS-L@LISTSERV.UGA.EDU Date: 05/18/2011 05:34 PM Subject: Re: PROC MEANS/WEIGHTS - any way to output normalised weight values? Sent by: "SAS(r) Discussion" Robin, Similarly, if one uses the resulting percentages as weights, they would end up with the same result. E.g., try: data tst3; input wn value; cards; 8.1 10.8 6.4 10.3 13.2 7.6 7.6 1.5 5.5 10.0 ; proc means data=tst3 mean; var value; weight wn; run; Art -----Original Message----- From: Arthur Tabachneck [mailto:art297@rogers.com] Sent: Wednesday, May 18, 2011 6:04 PM To: 'Robin R High' Cc: 'SAS-L@LISTSERV.UGA.EDU' Subject: RE: PROC MEANS/WEIGHTS - any way to output normalised weight values? Robin, I'm not sure what you are questioning, although I obviously may have misunderstood what Andrew was asking for. A weighted mean is simply the sum of the products (given your example the sum of the wn*value variables), divided by the sum of the weighting variable (in your example the sum of wn). As shown below, I think, the same analyses on tst2 provide the same result. Am I missing something here? Art DATA tst; input wn value; cards; 8.1 10.8 6.4 10.3 8.3 7.6 7.6 1.5 5.5 10.0 4.9 7.6 ; DATA tst2; input wn value; cards; 8.1 10.8 6.4 10.3 13.2 7.6 7.6 1.5 5.5 10.0 ; proc means data=tst mean; var value; weight wn; run; proc means data=tst2 mean; var value; weight wn; run; proc freq data=tst order=data; tables value / nocum; weight wn; run; proc freq data=tst2 order=data; tables value / nocum; weight wn; run; -----Original Message----- From: Robin R High [mailto:rhigh@unmc.edu] Sent: Wednesday, May 18, 2011 5:31 PM To: Arthur Tabachneck Cc: SAS-L@LISTSERV.UGA.EDU Subject: Re: PROC MEANS/WEIGHTS - any way to output normalised weight values? Art, It produces the weights as Andrew described them if the variable cost is unique; however, given repeats in the value of interest: DATA tst; input wn value; cards; 8.1 10.8 6.4 10.3 8.3 7.6 7.6 1.5 5.5 10.0 4.9 7.6 ; proc freq order=data; tables value / nocum; weight wn; run; value Frequency Percent ------------------------------ 10.8 8.1 19.85 10.3 6.4 15.69 7.6 13.2 32.35 ** 1.5 7.6 18.63 10 5.5 13.48 ** Frequency is the sum of 8.3+4.9 since two observations have the value 7.6 Robin High UNMC From: Arthur Tabachneck To: SAS-L@LISTSERV.UGA.EDU Date: 05/17/2011 04:38 PM Subject: Re: PROC MEANS/WEIGHTS - any way to output normalised weight values? Sent by: "SAS(r) Discussion" Andrew, Does the following provide what you are looking for? proc means data=have mean; var cost; weight weight_number; run; proc freq data=have; tables cost; weight weight_number; run; HTH, Art ------- On Tue, 17 May 2011 16:45:28 -0400, Clapson, Andrew - PPD/DPP wrote: >Sorry...I wasn't being very clear. Maybe the request itself actually >doesn't even make much sense, haha. : ) > >Anyway, what I meant was, let's say I'm calculating a weighted average >of three prices: >\$10, \$15, \$20. > >These numbers have weights (measured in some arbitrary unit), >respectively, of let's say: >50, 100, 50. > >What I was curious about was if it would be possible to get an output >dataset (as an out from the PROC MEANS procedure) containing the >normalised weights - i.e. in a percentage or decimal form, in this case; >0.25, 0.5, 0.25, > >for instance. > > >Hope that clears things up...someday I'll learn my lesson about >ambiguous postings.... >Thanks > >Andy > > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of >Data _null_; >Sent: May-17-11 3:49 PM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Re: PROC MEANS/WEIGHTS - any way to output normalised weight >values? > >Ok I'll bite. > >I don't know what you are asking for. I googled briefly but found >nothing that seems to fit your question. > >Can you explain in more detail for this dumb hillbilly. Especially >the trivial part. > > > >On Tue, May 17, 2011 at 9:40 AM, Clapson, Andrew - PPD/DPP > wrote: >> Hey all, >> >> Just curious if it is at all possible to get an output dataset of >> weights used in a Weights statement? >> >> Let's say, for example, for weight variables used in calculated a >> weighted mean via the PROC MEANS procedure. While I doubt that SAS >> explicitly calculates individual normalised weights, is there perhaps >> some functionality to extract the weights in this form? (Yes, I >realise >> the calculation is trivial, but if SAS can do it within the PROC MEANS >> procedure, it will save me a step.) >> >> Thanks for the help, >> >> Andy Clapson >> ```

Back to: Top of message | Previous page | Main SAS-L page