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 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 21 Jan 2008 09:55:17 -0500
Reply-To:     "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Organization: Internet News Service
Subject:      Re: Largest value in a symmetric matrix
Comments: To:

Stefan Pohl wrote: > Hi SAS-group, > > I want to know which is the largest value in the following matrix > > id var1 var2 var3 var4 > 1 0 1 2 1 > 2 1 0 5 4 > 3 2 5 0 3 > 4 1 4 3 0 > > the matrix is symmetric > > How can I do this?

You can use the MAX function and a retained variable.

------ data _null_; retain maxvalue;

set MyData end=end; maxvalue = max (maxvalue, of var1-var4);

if end then call symputx('maxvalue',maxvalue); run;

------ The issue of symmetry does not come into play. A more complex looping approach that is symmetry aware could perform 1/2 the number of comparisons to arrive at the answer. This does not mean it would always take less time -- the MAX function might be able to loop faster internally than some externally managed loop.

-- Richard A. DeVenezia

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