Date: Mon, 8 Apr 1996 12:15:09 +0100
Reply-To: John Whittington <johnw@MAG-NET.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: John Whittington <johnw@MAG-NET.CO.UK>
Subject: Re: Weighted Average Means.
On Mon, 8 Apr 1996, Alex Wolf <wolfam@WERPLE.NET.AU> wrote:
>I am faced with a problem where I am filling Orders with a number of Lines
each having
>an average length and weight in Kilograms. I can do a Proc Summary using the
>Weight = Kilogram to produce a weighted Average Mean.
>
>In an example:
>
>Line1 Kilograms = 300, Avg Length = 21.5
>Line2 Kilograms = 450, Avg Length = 19.5
>
>Line? Kilogram = 250 Avg Length = ???
>
>Order needs 1000 Kilograms and an Average Length of 21.0. I need to know
what the average length of a third Line to satisfy Order average requirement.
Alex, I am not convinced that I understand exactly how you want to do this
(in terms of where the data is coming from and going to), but the following
will do what I understand of the required arithmetic for you:
data info ;
input kilo avlength ;
cards ;
300 21.5
450 19.5
;
run ;
data _null_ ;
set info nobs = obs ;
wt_len = kilo * avlength ;
sum_kilo + kilo ;
sum_wtl + wt_len ;
if _N_ = obs then do ;
kilogram = 1000 - sum_kilo ;
avg_len = (21000 - sum_wtl) / kilogram ;
put 'LineX ' kilogram = ' ' avg_len = ;
end ;
run ;
John
-----------------------------------------------------------
Dr John Whittington, Voice: +44 1296 730225
Mediscience Services Fax: +44 1296 738893
Twyford Manor, Twyford, E-mail: johnw@mag-net.co.uk
Buckingham MK18 4EL, UK CompuServe: 100517,3677
-----------------------------------------------------------