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 (October 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 2 Oct 2011 21:10:42 -0400
Reply-To:   Quentin McMullen <qmcmullen.sas@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Quentin McMullen <qmcmullen.sas@GMAIL.COM>
Subject:   Re: non-integers, logic expression and %eval( )
Comments:   To: bbser 2009 <bbser2009@gmail.com>
In-Reply-To:   <000001cc8165$930f1160$b92d3420$@com>
Content-Type:   text/plain; charset=ISO-8859-1

Hi again Max,

%eval does not know that non-integers are numbers. It thinks they are character strings.

So when you ask for %eval(10.1+2), %eval things you are trying to add two character strings and give you an error because it knows you can't add character strings.

82 %put %eval(10.1+2); ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 10.1+2

However, %eval is happy to *compare* two character strings:

70 %put %eval(b>a); 1

So when you ask %eval to compare 10.1 and 2, it sees 10.1 as a character, and says "oh, Max wants me to compare the character string 10.1 to the character string 2, I can do that", which is why it happily does the comparison, and returns a 0 because the character string 10.1 is not greater than the character string 2.

73 %put %eval(10.1>2); 0

Kind Regards, --Quentin

On Sun, Oct 2, 2011 at 8:44 PM, bbser 2009 <bbser2009@gmail.com> wrote: > Hi there, > > Just a quick question. > It was that non-integers should not occur in %eval(). > But why does the first one below result in an error message in the log while > the second one not? > > %put %eval(10.1+2); > %put %eval(10.1>2); > > Thank you for commenting. > > Regards, Max > (Maaxx) >


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