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 (January 2010, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 12 Jan 2010 09:39:00 -0500
Reply-To:   "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Subject:   Re: sorting arrays
In-Reply-To:   <007f01ca932d$fe70b0d0$fb521270$@net>
Content-Type:   text/plain; charset=us-ascii

> From: Ted Clay > Subject: sorting arrays > > I am hoping to improve on the technique for sorting values > within an array > (in a data step), which I implement using a macro. > > Is there a call or other non-macro solution to do this?

This is a FAQ.

I have posted some of Donald Knuth's sorting and searching algorithms written in SAS

Here is the sas community wiki page for Shell Sort:

http://www.sascommunity.org/wiki/Knuth_Shell_Sort

You can search the SAS-L archives near the 2002-August date to see the other programs.

Ron Fehd the algorithm maven CDC Atlanta GA USA RJF2 at cdc dot gov

> Outputting the > data and using proc sort is not an option. > > The program, whose purpose is to sort array B_ randomly, > looks like this: > > > > Data testdata; > > Array a_ {*} a1-a7; > > Array b_ {*} b1-b7; > > Do i=1 to 7; > > A_(i)=ranuni(15151); > > B_(i)=I; > > End; > > Run; > > > > Data result; > > Set testdata; > > Array a_ {*} a1-a7; > > Array b_ {*} b1-b7; > > %sortaray(by=a_,others=b_); > > Run; > > > > proc print data=result; > > var b:; > > run; > > > > Produces . > > > > > Obs b1 b2 b3 b4 b5 b6 b7 > > > > 1 4 5 1 6 7 3 2 > >


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