BookmarkSubscribeRSS Feed
Kiko
Fluorite | Level 6

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! 

 

 

1 REPLY 1
novinosrin
Tourmaline | Level 20

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 604 views
  • 0 likes
  • 2 in conversation