LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2002, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 11 Mar 2002 10:40:57 -0800
Reply-To:   John Power <ecarta@TELUS.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   John Power <ecarta@TELUS.NET>
Subject:   Re: Selecting records by date using SQL
Comments:   To: "Chakravarthy, Venky" <Venky.Chakravarthy@pfizer.com>
In-Reply-To:   <7D526C31B4B34F409A2DC54FCD4508ECA08FE9@anagrdexm03.research.aa.wl.com>
Content-Type:   text/plain; charset="iso-8859-1"

Thanks to both David and Venky for their suggestions. I should have said that I was running the query from a GIS using ODBC to link to SAS. Therefore, I assume I can't use Proc SQL. After posting my question I did find a reference in the archives to using SELECT DISTINCT COUNT based on an example from Joe Celko's "SQL for Smarties". I'll try and use that.

John

John M. Power E-CARTA Services 2241 Blenheim Street Vancouver, BC Canada V6K 4J4 Phone: (604) 734-8239 Fax: (604) 733-3943 e-mail: ecarta@telus.net

-----Original Message----- From: Chakravarthy, Venky [mailto:Venky.Chakravarthy@pfizer.com] Sent: Monday, March 11, 2002 5:39 AM To: 'John Power'; SAS-L@LISTSERV.UGA.EDU Subject: RE: Selecting records by date using SQL

John,

Assuming that the data is already sorted in descending order, then

Proc Sql INOBS = 15 ;

should produce the desired results. Also note that David's solutions sorts the data for the output and not the input.

Kind Regards,

Venky #****************************************# # E-mail: swovcc@hotmail.com # # Phone: (734) 622-1963 # #****************************************#

-----Original Message----- From: John Power [mailto:ecarta@TELUS.NET] Sent: Sunday, March 10, 2002 6:35 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Selecting records by date using SQL

In Access there is a method of selecting, for example, the most recent 15 records. You order the records in descending order by date, then use "SELECT TOP 15 FROM.....". I want to do the same thing in SAS using a SQL Query from an external program. I know how to order the records in descending order, however "TOP" doesn't seem to work. Is there an equivalent command?

Thanks


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