Date: Thu, 19 May 2011 09:38:46 -0400
Reply-To: Andrew.Clapson@STATCAN.GC.CA
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Clapson, Andrew - PPD/DPP" <Andrew.Clapson@STATCAN.GC.CA>
Subject: Re: PROC MEANS/WEIGHTS - any way to output normalised weight
values?
In-Reply-To: <1612D1AFA2C14844B7E45E34418B22CE@2235d1002>
Content-Type: text/plain; charset="us-ascii"
Hey Art, Robin,
Actually, I do need the weights separated, even when they are non-unique
- 'collapsing' them into their respective sums would work for the
purposes of that calculation, but actually wouldn't suit my purposes.
I want the individual, normalised weights. Although, of course the
actual mean is also important. : )
I was just looking for a shortcut here...
Andy
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Arthur Tabachneck
Sent: May-18-11 6:04 PM
To: 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 <art297@ROGERS.COM>
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" <SAS-L@LISTSERV.UGA.EDU>
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
<Andrew.Clapson@STATCAN.GC.CA> 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
><Andrew.Clapson@statcan.gc.ca> 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
>>