Date: Wed, 8 Mar 2000 15:04:19 -0700
Reply-To: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
Subject: Re: Celko's median using SQL
Content-Type: text/plain; charset=us-ascii
Without seeing the code and data, it would be hard to say why your query failed.
I'm not greatly surprised that it took a long time, though: it's doing an unoptimized
Cartesian join, and it's doing a lot of comparisons. Did you have a lot of observations?
One reason that a median function isn't more widely available in SAS is that it's
Not sure what you mean about AVG and SUM; MEAN and SUM are available as
Development Manager, Technical Group
METRICS Department, First Health
West Sacramento, California USA
>>> <xbguan@YAHOO.COM> 03/08/2000 12:31 pm >>>
I tried the similar query on my own table. It took several hours to run
and return 0 rows. Any idea?
Also, is it easy to create a function similar to AVG, SUM, etc.?
Thanks a lot!
In article <email@example.com>,
> >> From SQL For Smarties: Advanced SQL Programming, Second Edition, by
> Joe Celko, Morgan Kaufman Publishers, 2000 ...
> SELECT AVG(DISTINCT weight)
> FROM (SELECT ...
> I actually think that SELECT AVG(weight)... is a better choice because
> it will do a weighted median. For example, if the central values are
> (2,2,3,3,3) the SELECT AVG(DISTINCT) version will give you (5/2) =
> while the SELECT AVG() version will give you 13/5 = 2.6, which is a
> better measure of central tendency.
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Sent via Deja.com http://www.deja.com/
Before you buy.