Date: Tue, 18 Oct 2005 17:50:50 -0400
Reply-To: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject: Re: PROC SQL:How to Calculate the MEDIAN with SQL
Content-Type: text/plain; charset="iso-8859-1"
Some may find it surprising to hear me say this. I wouldn't use SAS SQL to compute a median. SAS offers a number of proven algorithms for computing a median. SQL does not handle computations based on ordering and ranking well, and the end game in a median computation has some odd twists. Better to extract a median into a macrovariable ... A number of SAS/Base procedures compute a median. One can use a SAS SQL view as a data source.
From: firstname.lastname@example.org on behalf of Gary W. Shaw
Sent: Tue 10/18/2005 5:25 PM
Subject: PROC SQL:How to Calculate the MEDIAN with SQL
Has anyone used SQL (in SAS or any other DBS) to determine the MEDIAN?
I like to use SQL to find counts, sums and other stats.
But SAS/SQL and I guess another ANSI SQL, does not have a Meidan()
My internet research has pulled up some solutions for SQL????
I have developed a solution in SAS/SQL ordering the data and using the
The solution works OK, but not straight SQL. That is it requires a few
This email transmission and any documents, files or previous email
messages attached to it may contain information that is confidential or
legally privileged. If you are not the intended recipient or a person
responsible for delivering this transmission to the intended recipient,
you are hereby notified that you must not read this transmission and
that any disclosure, copying, printing, distribution or use of this
transmission is strictly prohibited. If you have received this transmission
in error, please immediately notify the sender by telephone or return email
and delete the original transmission and its attachments without reading
or saving in any manner.