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 2011, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 23 Feb 2011 19:46:28 -0500
Reply-To:     Arthur Tabachneck <art297@ROGERS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@ROGERS.COM>
Subject:      Re: MAX() function over character values
Comments: To: "Kirby, Ted" <ted.kirby@LEWIN.COM>


I would presume so given a large number of variables. However, if only 3 are involved, the following appears to work:

data have; input s1 $ s2 $ s3 $; s_max = s1 max s2 max s3; s_min = s1 min s2 min s3; cards; x y a he aa zz aa zz he 1 3 2 3 1 2 ;

Art ------- On Wed, 23 Feb 2011 19:31:57 -0500, Kirby, Ted <ted.kirby@LEWIN.COM> wrote:

>However, it appears from the examples that the min and max operators can >take only two operands. Thus, some sort of looping structure would need >to be used if you have a list of values of which you wanted the min or >max. > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of >Paul Dorfman >Sent: Wednesday, February 23, 2011 5:49 PM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Re: MAX() function over character values > >Art, > >Here is one place: > > >wer. >htm#a000780367.htm > >These have been around as long as I remember myself and SAS together. >They >are certainly described (with numerous usage examples) in Aster/Seidman >circa 1990. > >Kind regards >------------ >Paul Dorfman >Jax, FL >------------ > > >On Wed, 23 Feb 2011 17:26:11 -0500, Arthur Tabachneck ><art297@ROGERS.COM> >wrote: > >>Paul, >> >>That definitely works! Do you know if those operators are documented >>anywhere? I never even knew they existed. >> >>Art >>-------- >>On Wed, 23 Feb 2011 16:57:28 -0500, Paul Dorfman ><sashole@BELLSOUTH.NET> >>wrote: >> >>>Yevgeniy, >>> >>>Use the MAX/MIN operators instead: >>> >>>s_max = s1 max s2 ; >>>s_min = s1 min s2 ; >>> >>>You can also use them with numeric operands if you need to include >missing >>>values in the comparison. The descriptive statistics functions, >including >>>MIN/MAX ignore nulls - a side effect used to turn them into zeros via >>>expressions like sum(val,0). And, to boot, the operators execute >faster >>than >>>the respective functions. >>> >>>Kind regards >>>------------ >>>Paul Dorfman >>>Jax, FL >>>------------ >>> >>>On Wed, 23 Feb 2011 16:28:54 -0500, Bolotin Yevgeniy >>><YBolotin@SCHOOLS.NYC.GOV> wrote: >>> >>>>The MAX function only works on numbers in SAS 9.2 >>>> >/vi >>>>ewer.htm#a000245913.htm >>>> >>>>However, it works on both numbers and characters in SAS/IML 9.2 >>>> >lan >>>>gref_sect169.htm >>>> >>>> >>>>Is there a character-capable MAX function in SAS Base that I can use? >>>> >>>>(surprisingly enough, PROC SQL seems to have the same limitation) >>>> ERROR: Function MAX requires a numeric expression as argument 1. >>>> >>>> >>>> >>>> >>>>data _z; >>>>length z $1.; >>>>z = max('2','3','a'); >>>>run; >>>> >>>> >>>>NOTE: Character values have been converted to numeric values at the >>>>places given by: >>>> (Line):(Column). >>>> 3053:9 3053:13 3053:17 >>>>NOTE: Numeric values have been converted to character values at the >>>>places given by: >>>> (Line):(Column). >>>> 3053:5 >>>>NOTE: Invalid numeric data, 'a' , at line 3053 column 17. >>>>z=3 _ERROR_=1 _N_=1 >>>> >>>> >>>>Thanks >>>> >>>>SAS 9.2 >>>>WinXP SP3 >************* IMPORTANT - PLEASE READ ******************** > >This e-mail, including attachments, may include confidential and/or proprietary information, >and may be used only by the person or entity to which it is addressed. If the reader of this >e-mail is not the intended recipient or his or her authorized agent, the reader is hereby >notified that any dissemination, distribution or copying of this e-mail is prohibited. If you >have received this e-mail in error, please notify the sender by replying to this message >and delete this e-mail immediately. >

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