BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GunnerEP
Obsidian | Level 7

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 hadoop;);
%end;
%end;
%else
%str(execute(DROP TABLE abcd PURGE) by hadoop;);

 

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 hadoop;);
%end;
%end;
%else
%str(execute(DROP TABLE abcd PURGE) by hadoop;);


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.

1 ACCEPTED SOLUTION

Accepted Solutions
DanielSantos
Barite | Level 11

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

10 REPLIES 10
LaurieF
Barite | Level 11

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.

DanielSantos
Barite | Level 11

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

GunnerEP
Obsidian | Level 7

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.)

DanielSantos
Barite | Level 11

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

GunnerEP
Obsidian | Level 7

I do have options minoperator; in my code.

DanielSantos
Barite | Level 11

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

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

Astounding
Opal | Level 21

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.

ballardw
Super User

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

 

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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