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.
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
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.
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
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.)
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
I do have options minoperator; in my code.
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
And use the "little running man" icon to post SAS code, as that will prevent the display of colon/closing bracket as a smiley:
🙂
:)
Why are you dropping tables based on some condition. Doesn't that defeat the purpose of audit trails and such like?
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.
You should show the macro definition starting from the %MACRO statement through to the %MEND statement.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.