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 16:57:28 -0500
Reply-To:     Paul Dorfman <sashole@BELLSOUTH.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Dorfman <sashole@BELLSOUTH.NET>
Subject:      Re: MAX() function over character values
Comments: To: Eugene Bolotin <YBolotin@SCHOOLS.NYC.GOV>

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 >http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/vi >ewer.htm#a000245913.htm > >However, it works on both numbers and characters in SAS/IML 9.2 >http://support.sas.com/documentation/cdl/en/imlug/59656/HTML/default/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


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