DATA Step, Macro, Functions and more

ERROR: A character operand was found in the %EVAL function or %IF condition where..

Reply
Occasional Contributor
Posts: 10

ERROR: A character operand was found in the %EVAL function or %IF condition where..

Hi, 

 

Here's my code: 

 


%macro InitializeVariables;
%let _EFIERR_ = 0; /* initialize the ERROR detection macro variable */
%let _count_ = 0; /* initialize record count macro variable */
%mend;

%macro CheckForErrors;
/*if there is error , then _EFIERR_=1, else _EFIERR_=0 */
%if &_EFIERR_=0 %then %PUT NOTE: &=_EFIERR_ - no read errors detected with &_count_ records read.;
%else %PUT WARNING: &=_EFIERR_ - some read errors were detected while reading &_count_ records.;
%mend;

%InitializeVariables

 

*rest of my code* 

 


count+1;
if _ERROR_ then call symputx('_EFIERR_',1); /*set ERROR detection macro*/
if last then call symputx ('_count_',count);run;
%CheckForErrors 

 

I am getting the following warning & error messages: 

 

WARNING: Apparent symbolic reference _EFIERR_ not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a
numeric operand is required. The condition was: &_EFIERR_=0
ERROR: The macro CHECKFORERRORS will stop executing.

 

Does anyone know how to fix this? What am I missing here? Thank you! 

 

 

PROC Star
Posts: 169

Re: ERROR: A character operand was found in the %EVAL function or %IF condition where..

First of all, your macrovariables created during the execution of %InitializeVariables will cease to exist being local in scope, i.e they are local macro variables that exists only during the execution of macro %Initialize. Add a %global statement before %let and make it global like this:

%macro InitializeVariables;

%global _EFIERR_  _count_ ;
%let _EFIERR_ = 0; /* initialize the ERROR detection macro variable */
%let _count_ = 0; /* initialize record count macro variable */
%mend;

Ask a Question
Discussion stats
  • 1 reply
  • 94 views
  • 0 likes
  • 2 in conversation