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