An Idea Exchange for SAS software and services

Comments
by Super User
on ‎05-25-2017 11:08 AM

If your first example is actually one line as it appears as posted in the forum I have little sympathy as that is way long for a single line of text.

 

In DM when I run

data dummy;
   * as single line comment with a ' embedded in it;/* This is a really long comment to generate 262 characters after the single quotation mark. I sure wish the macro compiler could treat a single quote within a comment as just that,  a comment, instead of treating the single quote as a special character.It works with slash-asterisk style commenting but not other commenting styles.*/

   set junk;
run;

I have no problem. So I am not sure what you may be attempting or where your problem is comming from.

 

It isn't clear if your problem involves the macro language or not. If so then a single comment *this comment; is not a good idea in general (the macro processor does not see it as comment per se). And I don't use the %* style of comment; and stick with /* style comments*/ every where just to simplify things.

by Super Contributor
on ‎05-25-2017 07:14 PM

"If your first example is actually one line as it appears as posted in the forum I have little sympathy as that is way long for a single line of text."

 

It's not, it's a shortcoming of the forum software.  I pasted some code edits inside the code tags, the code looked fine in the editor, but was reformatted when I posted.  Unlike other areas of the forum, I can't see a way to edit ballot ideas once they're posted.  So I have little sympathy for your smug comment.

 

"I have no problem. So I am not sure what you may be attempting or where your problem is comming (sic) from."

 

If you ran my tests as posted the issue would be obvious.

 

"If so then a single comment *this comment; is not a good idea in general (the macro processor does not see it as comment per se). And I don't use the %* style of comment; and stick with /* style comments*/ every where just to simplify things."

 

Good for you, I have a different coding style, and use all three forms of commenting.

 

Sure, "don't do that" to work around poor software design is one approach.  I prefer to offer suggestions on how the software could be improved.

by PROC Star
‎06-14-2017 10:32 AM - edited ‎06-14-2017 10:35 AM

I think it's fair for * comments and %* comments to work differently.  The * commment is a comment in the SAS language, and the %* is a comment in the macro language.  Sometimes this difference is useful, for example a macro can generate * comments that will show up in the log as generated code when MPRINT is used.

 

So it doesn't bother me that a * comment that has an unmatched quote causes problems for the macro compiler, since it doesn't know about * comments.

 

But, it does bother me that unmatched  quotes inside of a %* comment cause a problem :

%macro comment;
%* Workaround SAS's blah;
%mend comment;

 

As I understand it, these cause a problem in part because %* comments are tokenized, while /* */ comments are not.  %* comments are also stored as part of the macro definition. 

 

I don't see a benefit to tokenizing %* comments.  I suppose some people might like that %* comments are stored as part of the macro definition, but it's not a benefit for my use of the macro language.  So I'd be happy to see %* comments treated the same as /* */ comments, if that were possible.

 

I've been bitten by this enough to avoid unmatched quotes in comments, because I assume any code/comment I write might eventually wind up in a macro.  But I agree, this is a workaround.  And when convering other people's code to  macros, there is always the risk that an apostrophe will sneak in.

Idea Statuses
Top Liked Authors