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 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 11 Mar 2008 12:33:24 -0700
Reply-To:     "Pardee, Roy" <pardee.r@GHC.ORG>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Pardee, Roy" <pardee.r@GHC.ORG>
Subject:      Re: How to Proc SQL select top N records?
In-Reply-To:  A<200803111904.m2BGU0Ft027397@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Couple of notes here:

1) You may want to add the option NOWARN after the outobs= spec to suppress WARNINGs in your log due to th outobs spec. 2) If you have a WHERE clause, note that SAS will process your entire dataset in order to apply it--so this isn't something to do for performance reasons.

HTH,

-Roy

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Steven Raimi Sent: Tuesday, March 11, 2008 12:04 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: How to Proc SQL select top N records?

On Tue, 11 Mar 2008 11:40:29 -0700, Ruve <bandbig@GMAIL.COM> wrote:

>How to Proc SQL select top N records in SAS? > >Just like "Select Top 10" in SQL Server? I just want to see the top 10

>results without having to saving all query results into a dataset. > >Thanks!

proc sql outobs=10; /* limit to first 10 results */ select groupvar, count(*) from table group by groupvar order by 2 desc; /* this is how you make them the TOP 10 */ run;

Steve Raimi


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