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 (April 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 2 Apr 2009 13:59:57 -0700
Reply-To:   Richard <rdevenezia@WILDBLUE.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Richard <rdevenezia@WILDBLUE.NET>
Organization:   http://groups.google.com
Subject:   Re: PROC SQL: top 5 in each group
Comments:   To: sas-l@uga.edu
Content-Type:   text/plain; charset=ISO-8859-1

On Mar 31, 1:26 pm, bruce.gil...@FRB.GOV ("Gilsen, Bruce F.") wrote: > SAS > Institute recommended PROC SORT+DATA step, not PROC SQL.

I am guessing it was a SORT DESCENDING, DATA, SORT ASCENDING.

An efficient technique would perform a SORT ASCENDING followed by a double DOW DATA to obtain the top N.

proc sort data=have; by year assets; run;

data top5have; do _n_ = 1 by 1 until (last.year); set have; by year assets; end;

do _i_ = 1 to _n_; set have; if _i_ > _n_-5 then OUTPUT; end; run;

-- Richard A. DeVenezia http://www.devenezia.com

p.s. The reflexive SQL join only works correctly when there are no duplicates in the FROM tables. p.p.s Oracle has some fantastic summarization features for within partition (by group) processing.


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