Help using Base SAS procedures

ERROR: Macro keyword DO appears as text

Accepted Solution Solved
Reply
Contributor
Posts: 35
Accepted Solution

ERROR: Macro keyword DO appears as text

Country used to come in this format - ARG

 

%if (&&cntry_cd&i = ARG) or %eval(&&cntry_cd&i. IN &list.) %then %do;
%do a = 0 %to 9;
%str(execute(DROP TABLE abc PURGE) by hadoopSmiley Wink;
%end;
%end;
%else
%str(execute(DROP TABLE abcd PURGE) by hadoopSmiley Wink;

 

New Country format - 'ARG'

 

%if (%bquote(&qctry. = %str(%')ARG%str(%')) or %eval(%bquote(&qctry.) IN &list.) %then %do;
%do a = 0 %to 9;
%str(execute(DROP TABLE abc PURGE) by hadoopSmiley Wink;
%end;
%end;
%else
%str(execute(DROP TABLE abcd PURGE) by hadoopSmiley Wink;


ERROR MESSAGE:

ERROR: Macro keyword DO appears as text.
ERROR: A dummy macro will be compiled.
ERROR: Macro keyword DO appears as text.
ERROR: Macro keyword END appears as text.
ERROR: Macro keyword END appears as text.
ERROR: There is no matching %IF statement for the %ELSE.

 

I am not sure why am i getting this error, i am trying to mask the quotes as per the new country format.


Accepted Solutions
Solution
‎01-13-2017 07:26 AM
Super Contributor
Posts: 474

Re: ERROR: Macro keyword DO appears as text

[ Edited ]

Hi.

 

Well, that's because you are missing this system option:

 

options MINOPERATOR;

 

More on this here: http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a003092012.htm

 

Daniel Santos @ www.cgd.pt

View solution in original post


All Replies
Super Contributor
Posts: 252

Re: ERROR: Macro keyword DO appears as text

Can you post the whole macro, or more significant parts of it, and the actual call to the macro as well, please? We need some more context.

Super Contributor
Posts: 474

Re: ERROR: Macro keyword DO appears as text

[ Edited ]

Hi.

 

You seem to have unbalanced parenthesis here:


%if (%bquote(&qctry. = %str(%')ARG%str(%')) or %eval(%bquote(&qctry.) IN &list.) %then %do;

 

remove the first one.

 

 

Daniel Santos @ www.cgd.pt

Contributor
Posts: 35

Re: ERROR: Macro keyword DO appears as text

Posted in reply to DanielSantos

Thanks for that. but now ran to a different error.

 

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:


(%bquote(&qctry. = 'ARG')) or %eval(%bquote(&qctry.) IN &list.)

Solution
‎01-13-2017 07:26 AM
Super Contributor
Posts: 474

Re: ERROR: Macro keyword DO appears as text

[ Edited ]

Hi.

 

Well, that's because you are missing this system option:

 

options MINOPERATOR;

 

More on this here: http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a003092012.htm

 

Daniel Santos @ www.cgd.pt

Contributor
Posts: 35

Re: ERROR: Macro keyword DO appears as text

Posted in reply to DanielSantos

I do have options minoperator; in my code.

Super Contributor
Posts: 474

Re: ERROR: Macro keyword DO appears as text

[ Edited ]

Then you need to show us what are the values for those macro variables.

 

set:

 

options notes mprint symgen;

 

Run the code, and show us the log.

 

Daniel Santos @ www.cgd.pt

 

Super User
Posts: 7,868

Re: ERROR: Macro keyword DO appears as text

And use the "little running man" icon to post SAS code, as that will prevent the display of colon/closing bracket as a smiley:

 

Smiley Happy

:)
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,997

Re: ERROR: Macro keyword DO appears as text

Why are you dropping tables based on some condition.  Doesn't that defeat the purpose of audit trails and such like?

Super User
Posts: 5,518

Re: ERROR: Macro keyword DO appears as text

[ Edited ]

You should be able to use your original code, even when the form of the incoming data changes.  However, you may need to construct &LIST differently.  The elements within need to be quoted in order to find a match.

 

So if &&CNTRY_CD&I really does resolve to 'ARG', this comparison finds a match:

 

%if (&&cntry_cd&i = 'ARG') then ...

 

You won't need the quoting functions.  However, change is needed if &&cntry_cd&i resolves to ARG and not 'ARG'.  In that case, the simplest change would be:

 

%if (%str(')&&cntry_cd&i%str(') = 'ARG') then ...

 

While that should work, if it doesn't work, you may need to apply:

 

%if (%unquote(%str(')&&cntry_cd&i%str(') = 'ARG') then ...

 

If the values you are comparing to have quotes around them, such as 'ARG', the %BQUOTE function will not add those quotes.

Super User
Posts: 11,343

Re: ERROR: Macro keyword DO appears as text

You should show the macro definition starting from the %MACRO statement through to the %MEND statement.

 

 

☑ This topic is solved.

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

Discussion stats
  • 10 replies
  • 402 views
  • 1 like
  • 7 in conversation