Date: Wed, 23 Feb 2011 17:26:11 -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
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
>>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
|