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:   Mon, 11 Jan 2010 18:21:48 -0800
Reply-To:   Ted Clay <tclay@ASHLANDHOME.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Ted Clay <tclay@ASHLANDHOME.NET>
Subject:   sorting arrays
Content-Type:   text/plain; charset="us-ascii"

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? 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