@Amir wrote:
I expect you might already be aware of this, but according to the documentation on comments part of the restrictions for the *message; style of comment syntax says:
This form of comment cannot be used to hide text from the SAS macro facility.
So your experience does appear to be consistent with the documentation, i.e., the apostrophe "cannot be used to hide text from the SAS macro facility."
It then also goes on to give the tip:
Tip
When using comments within a macro definition or to hide text from the SAS macro facility, use this style comment:
/* message */
HTH.
Kind regards,
Amir.
Edit: Fixed typo.
Hi @Amir ,
I read that documentation excerpt differently. I'm not trying to hide anything at all from the macro processor. Instead, I just want a perfectly legal statement in open code - a * ; style comment statement containing an apostrophe (unbalanced single quote) - to not turn into a fatal error if I enclose that perfectly legal SAS code within a macro.
Run this code, and note the difference in the MPRINT output:
%macro test;
/* this is a slash-asterisk comment that will not show in MPRINT output */
%* this is a percent-asterisk comment that will not show in MPRINT output ;
* this is an asterisk comment that will show in MPRINT output ;
data one;x=1;run;
%mend;
options mprint;
%test;
In my "real" SAS macros, I often want to use * ; style comments, if I want the MPRINT output to document what the generated SAS code is doing.
Look, I get it...SAS macro is what 30+ years old? The C code implementing the macro tokenizer probably hasn't been touched in many many years. The original SAS macro developers may have retired (although SAS does have incredible employee loyalty; who'd want to retire when you've got that cafeteria for all your meals?) Fixing this design issue would require programmer's time, testing, backwards compatibility, and other issues. And what is the return on investment to SAS to fix this design issue? Probably less than nil. Spend the programmer's time on stuff that will make money.
And yeah, in a "real" macro, I would just get angry at the current behaviour, then fix the problem. But in my original use case (using an uncalled macro to comment out a block of code), the current behaviour is certainly a PITA.
Like I said, my original post is more of a rant. The rant will either get sympathy and perhaps some traction, or die a quick death. Probably the latter.
P.S.: Since my original post, I've discovered the workaround that saves me from having to restart the workspace server.
SAS Log:
27 %macro test;
28 /* this is a slash-asterisk comment that will not show in MPRINT output */
29 %* this is a percent-asterisk comment that won't show in MPRINT output ;
30 * this is an asterisk comment that will show in MPRINT output ;
31 data one;x=1;run;
32 %mend;
33 options mprint;
34 %test;
35
36
37 GOPTIONS NOACCESSIBLE;
38 %LET _CLIENTTASKLABEL=;
39 %LET _CLIENTPROCESSFLOWNAME=;
40 %LET _CLIENTPROJECTPATH=;
41 %LET _CLIENTPROJECTPATHHOST=;
NOTE: The quoted string currently being processed has become more than 262 characters long. You might have unbalanced
quotation marks.
42 %LET _CLIENTPROJECTNAME=;
43 %LET _SASPROGRAMFILE=;
44 %LET _SASPROGRAMFILEHOST=;
So the problem is that a "quoted string" starts with the apostrophe, and the log message kicks in at 262 characters. So what's happened is I started creating a macro, but the macro thinks it contains a long unterminated string, which includes the %mend statement.
So now submit:
%mend;
;*';*";*/;quit;run; <<<<< this is optional but does not hurt
Keep submitting until you get this error:
ERROR: No matching %MACRO statement for this %MEND statement.
You should now have your workspace server back again.
(Now I've provided R&D even less reason to fix this annoying behaviour 😉 )
... View more