@Wolverine wrote:
To help recreate this issue, try running the following code from %macro to run;. Then run the full code. When I do this, i get an error about a quoted string and the files test_t1 and test_t2 are not created.
%macro example (ex);
data test_&ex.; set sashelp.cars; run;
%mend;
%example(t1)
%example(t2)
I can replicate the problem with your example, but I'm not sure the example really relates to a problem caused by pressing the CANCEL button while a macro is executing.
As you say, EG adds a magic string after every submission:
;*';*";*/;quit;run;
The intention of that string is to close any unclosed quotation blocks, or comment blocks.
But if you submit just part of the macro definition, without the %MEND, then when EG adds the magic string it will be like you submitted:
%macro example (ex);
data test_&ex.; set sashelp.cars; run;
;*';*";*/;quit;run;
In that case, you will have an unclosed macro definition, but you will also have an unclosed block of single quotes. This happens because * is not a comment in the macro language, so the quotation mark will be seen by the macro processor. See this related thread: https://communities.sas.com/t5/SAS-Programming/Apostrophe-in-a-comment-in-a-macro-why-after-40-years-does-SAS/td-p/680269
Personally, I really like that EG adds the magic string, but I understand why it was done. I wonder if it would have been safer to use a string like:
;%*';%*";*/;quit;run;
The %* comment would hide the unmatched quotes whether it appeared in a macro definition or in open code.
... View more