Sysevalf Overflow Error

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Sysevalf Overflow Error

Hello,

I am getting the below error code on var2. Any help is greatly appreciated!

 

ERROR: Overflow has occurred; evaluation is terminated.

 

%macro test
(_arg
);
%sysevalf(%superq(&_arg.)=,boolean)
%mend;

 

%macro test1;

%let var1 =32Z7905;
%let var2 =32D7905;

%do jj=1 %to 2;
%if %test(var&jj.)=0 %then %put IT WORKED &jj.;
%end;

%mend;

%test1;


Accepted Solutions
Solution
‎02-21-2017 03:11 PM
PROC Star
Posts: 1,290

Re: Sysevalf Overflow Error

Hi,

 

I really ike this method for testing for blank.  It's the method from:

http://changchung.com/download/022-2009.pdf

 

Unfortunately, %SYSEVALF() can handle both numeric values and text values, so when you pass it a value, it decides whether the value is a number or text, based on something guessing rules. 

 

%SYSEVALF() knows about exponential notation, and in the macro language 3D2 means 3*10**2, same as 3E2.

78   %put %sysevalf(3D2+1);
301

 

So when you pass your test macro 32D7905, %sysevalf overflows because it sees a very large number, 32*10**7905.

 

I think it would be better to have functions %EvalC and %EvalN which would only work with character / numeric arguments.  Please see ballot item I proposed:

https://communities.sas.com/t5/SASware-Ballot-Ideas/New-macro-functions-EvalC-and-EvalN/idi-p/266134

 

For the current situation, one hack is to add some constant text that will force %sysevalf to treat the value as text rather than numeric, e.g.:

33         %macro test(_arg)/des="check if _arg is null/only white space";
34           %sysevalf(Q%superq(&_arg.)=Q,boolean)
35         %mend;
36         %let var1=32D7905;
37         %put %test(var1);
0

So adding the letter Q forces %sysevalf() to see a text value, even when the value of &&&arg is numeric. But I don't really like that hack.  I also don't like adding double quote marks, e.g.  %sysevalf("%superq(&_arg.)" = "",boolean).

 

 

--Q.

View solution in original post


All Replies
Super User
Posts: 19,034

Re: Sysevalf Overflow Error

It helps if you take a minute to explain your question and problem. Include the log and error message as well. 

 

Is your macro test supposed to check for missing values or if a macro variable is defined?

Super User
Posts: 19,034

Re: Sysevalf Overflow Error

Also, check the parameters for SUPERQ

 

http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#p0ldeqll9sabzcn1j...


%SUPERQ(argument)
Required Argument
argument
is the name of a macro variable with no leading ampersand or a text expression that produces the name of a macro variable with no leading ampersand.

New Contributor
Posts: 3

Re: Sysevalf Overflow Error

Hi Reeza,

I am trying to loop through a list of macro variables and verify the aren't missing. The problem I am having is it works for almost any other string. If I take the D out of var2 it also works, but other alphas don't cuase an issue. Below is the log. Thank you for your time. Smiley Happy

 

1         ;*';*";*/;quit;run;

2         OPTIONS PAGENO=MIN;

3         %LET _CLIENTTASKLABEL='Program1';

4         %LET _CLIENTPROJECTPATH=XXXXX

5         %LET _CLIENTPROJECTNAME=’test.egp';

6      

%LET _SASPROGRAMFILE=;

7        

8         ODS _ALL_ CLOSE;

9         OPTIONS DEV=ACTIVEX;

NOTE: Procedures may not support all options or statements for all devices. For details, see the documentation for each procedure.

10         ODS LISTING GPATH=&sasworklocation;

11         FILENAME EGHTML TEMP;

12         ODS HTML(ID=EGHTML) FILE=EGHTML ENCODING='utf-8' STYLE=Analysis

12       ! STYLESHEET=(URL="file:///C:/Program%20Files/SAS/SharedFiles(32)/BIClientStyles/4.2/Analysis.css")

12       ! ATTRIBUTES=("CODEBASE"="http://www2.sas.com/codebase/graph/v92/sasgraph.exe#version=9,2") NOGTITLE NOGFOOTNOTE

12       ! GPATH=&sasworklocation;

NOTE: Writing HTML(EGHTML) Body file: EGHTML

13        

14         %macro test

15         (_arg

16         )

17         /

18         des="check if _arg is null/only white space"

19         ;

20         %sysevalf(%superq(&_arg.)=,boolean)

21         %mend;

22        

23         %macro test1;

24        

25         %let var1           =32Z7905;

26         %let var2           =32D7905;

27        

28         %do jj=1 %to 2;

29         %if %test(var&jj.)=0 %then %put IT WORKED &jj.;

30         %end;

31        

32         %mend;

33        

34         %test1;

IT WORKED 1

ERROR: Overflow has occurred; evaluation is terminated.

ERROR: The macro TEST will stop executing.

35        

Solution
‎02-21-2017 03:11 PM
PROC Star
Posts: 1,290

Re: Sysevalf Overflow Error

Hi,

 

I really ike this method for testing for blank.  It's the method from:

http://changchung.com/download/022-2009.pdf

 

Unfortunately, %SYSEVALF() can handle both numeric values and text values, so when you pass it a value, it decides whether the value is a number or text, based on something guessing rules. 

 

%SYSEVALF() knows about exponential notation, and in the macro language 3D2 means 3*10**2, same as 3E2.

78   %put %sysevalf(3D2+1);
301

 

So when you pass your test macro 32D7905, %sysevalf overflows because it sees a very large number, 32*10**7905.

 

I think it would be better to have functions %EvalC and %EvalN which would only work with character / numeric arguments.  Please see ballot item I proposed:

https://communities.sas.com/t5/SASware-Ballot-Ideas/New-macro-functions-EvalC-and-EvalN/idi-p/266134

 

For the current situation, one hack is to add some constant text that will force %sysevalf to treat the value as text rather than numeric, e.g.:

33         %macro test(_arg)/des="check if _arg is null/only white space";
34           %sysevalf(Q%superq(&_arg.)=Q,boolean)
35         %mend;
36         %let var1=32D7905;
37         %put %test(var1);
0

So adding the letter Q forces %sysevalf() to see a text value, even when the value of &&&arg is numeric. But I don't really like that hack.  I also don't like adding double quote marks, e.g.  %sysevalf("%superq(&_arg.)" = "",boolean).

 

 

--Q.

New Contributor
Posts: 3

Re: Sysevalf Overflow Error

Thanks a bunch @Quentin!

Super User
Posts: 19,034

Re: Sysevalf Overflow Error

If you're trying to determine if a macro variable exists wouldn't %SYMEXIST be the way to do so?

 

PROC Star
Posts: 1,290

Re: Sysevalf Overflow Error

@Reeza it's not checking whether a macro variable exists; it's checking if a macro variable (that exists) has a value.  That is, checking that the macro variable is blank (or not). 

 

(Chung & King's paper goes into nice detail, defining the difference between checking for %isBlank and %isNull, both of which differ from %SYMEXIST)

Valued Guide
Posts: 2,177

Re: Sysevalf Overflow Error

I use sysevalf for logical calcs.
Which version would the proposed ballot item suggest?
PROC Star
Posts: 1,290

Re: Sysevalf Overflow Error

Sorry @Peter_C, I don't understand your question.

 

The proposed ballot suggests we have %EvalN and %EvalC.  Both would do logical evaluation.  %EvalN would do numeric comparisons, and %EvalC would do character comparisons.

 

So %EvalN(1e2=100) would return true, but %EvalC(1e2=100) would be false.

 

%EvalN(10>5) would be true, but %EvalC(10>5) would be false.

 

Point being that currently, %EVAL and %SYSEVALF both have to do some guessing (by different rules) to figure out if the arguments should be interpreted as text or numbers.  And that guessing often leads to surprises (for those who don't know the rules that are used to guess), or in this case an overflow, when SAS guesses a type which is different than the programmer intended.

 

On a related, point, even in the data step language, I'm not sure I really like that the CAT functions are happy with a numeric argument or character argument.  It's not really a problem, since in the data step language there is explicit typing.  But when people use CAT functions in the macro setting, they are often supriserd that sysfunc(CATX()) will get rid of leading zeroes on a number, and again, it's the same guessing problem, where CATX() has guessed that the argument is numeric rather than text.

 

79   %put %sysfunc(catx(|,001,002,003));
1|2|3
Valued Guide
Posts: 2,177

Re: Sysevalf Overflow Error

Re: Sysevalf Overflow Error [ New ]

@Quentin
your explanation which followed
"Sorry @Peter_C, I don't understand your question."
answered me perfectly, thank you
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 237 views
  • 2 likes
  • 4 in conversation