LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (October 2005, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: "Gary W. Shaw" <Gary.Shaw@austin.ppdi.com>
Content-Type: text/plain; charset="iso-8859-1"

Gary: 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. Sig

________________________________

From: owner-sas-l@listserv.uga.edu on behalf of Gary W. Shaw Sent: Tue 10/18/2005 5:25 PM To: sas-L@listserv.uga.edu 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() function? My internet research has pulled up some solutions for SQL???? I have developed a solution in SAS/SQL ordering the data and using the MONOTONIC() function. The solution works OK, but not straight SQL. That is it requires a few SQL steps. Thanks, Gary

______________________________________________________________________ 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.


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