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 (February 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 22 Feb 2001 09:11:04 -0800
Reply-To:     Nick Paszty <npaszty@ORGANIC.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nick Paszty <npaszty@ORGANIC.COM>
Subject:      Re: selecting min value across multiple vars
Comments: To: Stephen Finnigan <sfinnigan@NATHANASSOC.COM>
In-Reply-To:  <5F56203CB22CD211884400104B98235E75C5BB@nathan_mail.nathana
              ssoc.com>
Content-Type: text/plain; charset="us-ascii"; format=flowed

Hello Stephen.

You can't have SAS variable names begining with numbers so you'll have to do something to those column names before getting the data into SAS.

data junk; length minnm $32; input _1992 _1993 _1994 _1995 _1996;

minval=min(_1992,_1993,_1994,_1995,_1996);

array mv [*] _1992 _1993 _1994 _1995 _1996; do i=1 to dim(mv); if mv[i]=minval then do; call vname(mv[i],minnm); end; end;

drop i;

cards; 2 3 3 1 2 3 1 5 2 3 ; run;

proc print; run;

That should work for your particular case.

Cheers,

Nick At 11:44 AM 2/22/01 -0500, Stephen Finnigan wrote:

>I am attempting to find an elegant approach to selecting and retaining the >variable name containing the minimum value from a series of >variables. For example, > >In the data that follows, 1% is the minimum value. How would I retain >"1995" -- the variable name -- as a new variable value? Any ideas would >be most appreciated! > >Cheers, >Stephen > > 1992 1993 1994 1995 1996 >MarketShare 2% 3% 3% 1% 2% > >____________________________________________________ >Stephen Finnigan sfinnigan@nathanassoc.com >Nathan Associates Inc. 703.516.7731


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