Date: Tue, 26 Apr 2005 22:42:49 -0400
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject: Re: find maximum vaule in sas array
Jianping Zhu wrote:
> what is array is a temporary array?
> and how to find index of the max?
> THX
A surprisingly simple bubble loop should do it.
If you need to sort the array, search the archives for Dorfman Quicksort.
In version 9 there is also CALL SORTQ() for variable based arrays.
--------------------
data _null_;
array _x [ 1000000 ] _temporary_;
do _i = 1 to dim(_x);
_x[_i] = ranuni(123);
end;
* find index where maximum value occurs;
_imax = .;
do _i = 1 to dim(_x);
if _x[_i] > _max then do;
_max = _x[_i];
_imax=_i;
end;
end;
put _x[_imax]= _max=;
stop;
run;
--------------------
Richard A. DeVenezia -- Learn how to customize SAS Explorer
http://www.devenezia.com/downloads/sas/actions/