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 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: sas-l@uga.edu

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/


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