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 (August 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 13 Aug 2009 10:30:28 -0500
Reply-To:   yingtao <yingtaoliu@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
Comments:   To: "Data _null_," <iebupdte@gmail.com>
From:   yingtao <yingtaoliu@GMAIL.COM>
Subject:   Re: Min values
In-Reply-To:   <ce1fb7450908130748wba07eb7ne326d0471f714a5b@mail.gmail.com>
Content-Type:   text/plain; charset=ISO-8859-1

Thanks guys! The missing values are ignored by the min/max function. If we regard missing value as min value, will the idgroup way (by data_null_) still work?

On 8/13/09, Data _null_; <iebupdte@gmail.com> wrote: > I would transpose and use IDGROUP as follows. It works well since you > want the ties which causes a problem if you use SMALLEST and WHICHN > functions. > > If you have lots of data then a HASH solution will be faster, as > mentioned by Joe. > > data test; > input a b c d e; > id = put(_n_,z8.); > cards; > 1 1 5 4 4 > 2 3 8 5 . > ;;;; > run; > proc transpose; > by id; > run; > proc summary nway; > class id; > output idgroup(min(col1) out[2](col1 _name_)=min name); > run; > proc print; > run; > > > > On 8/13/09, yingtao <yingtaoliu@gmail.com> wrote: > > Hi all, > > I am trying to get the 2 minimum value and the corresponding variable names; > > > > data test; > > input a b c d e; > > cards; > > 1 1 5 4 4 > > 2 3 8 5 1 > > ; > > > > The desired data will be; > > a b c d e min1 min1_var min2 min2_var; > > 1 1 5 4 4 1 a 1 b > > 2 3 8 5 1 1 e 2 a > > ; > > > > I was trying to use sortn function. But the function mess up the variable name. > > Anybody has better idea? > > > > data need; > > set test ; > > array k[*] _numeric_; > > call sortn(of k[*]); > > min1 = k[1]; > > min1name=vname(k(1)); > > min2 = k[2]; > > run; > > > > > > Tao > > >

______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________


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