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 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 27 Apr 2009 15:58:13 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: To get lowest value among each observation
Comments: To: "./ ADD NAME=Data _null_," <iebupdte@gmail.com>
In-Reply-To:  <ce1fb7450904271356r774e1c56gee5cb2081d94f958@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Is that 9.2 or is it just undocumented???

-Joe

On Mon, Apr 27, 2009 at 3:56 PM, ./ ADD NAME=Data _null_; < iebupdte@gmail.com> wrote:

> Try Function WHICHN > > data test; > array _v[*] var1-var4; > input _v[*]; > low = min(of _v[*]); > lowVar = vname(_v[whichN(low,of _v[*])]); > datalines; > 20 30 15 40 > 17 50 25 30 > ;;;; > run; > proc print; > run; > > > On 4/27/09, Joe Matise <snoopy369@gmail.com> wrote: > > low = min(of var:) *or low = min(of var1,var2,var3,var4) or whatever > > convenient list you have; > > > > Getting the variable name is more complicated; I suppose the most > > straightforward way is > > data test; > > input > > var1 var2 var3 var4; > > datalines; > > 20 30 15 40 > > 17 50 25 30 > > ;;;; > > run; > > > > data want; > > set test; > > array vars var:; > > low = min(of var:); > > do _n_ = 1 to dim(vars) until (vars[_n_] = low); > > end; > > low_var = vname(vars[_n_]); > > run; > > > > which is sort of cheating and not particularly fast, but I can't think of > a > > better way off the top of my head. > > -Joe > > > > > > On Mon, Apr 27, 2009 at 3:15 PM, Sclavid Raj <sskonda@aol.com> wrote: > > > > > Hello all, > > > > > > I have four variables and 2000 obs. I need to get the lowest value in > each > > > observation (row) among four variables in a separate variables for > lowest > > > value, as well as that variable name. > > > > > > Here is the example: > > > > > > var1 var2 var3 var4 > > > 20 30 15 40 > > > 17 50 25 30 > > > . . > > > . . > > > . . > > > > > > Output should be like this; > > > var1 var2 var3 var4 low low_var > > > 20 30 15 40 15 var3 > > > 17 50 25 30 17 var1 > > > . . > > > . . > > > . . > > > > > > I think i am clear. > > > > > > Thanks in advacne. > > > > > > Sclavid. > > > > > >


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