BookmarkSubscribeRSS Feed
jlwatts
Calcite | Level 5

I tried to comment out a macro by placing /*  before the %macro and */ after the %mend;  But for some reason that did not work:

 

Macro begin 1.png

 

I actually had to place another /* before the PROC SQL statement:

Macro begin 2.png

 

Any suggestions as to why this is the case?  I had originally made my change in a text editor, not SAS EG 8.  So, the process threw errors when I ran the code.

4 REPLIES 4
Tom
Super User Tom
Super User

Did SAS actually re-define the macro in in the first case when you ran the code?

Or are you just talking about the colors you see in the pictures you posted?  That is are just just asking about the algorithm that the editor you are using uses to color the text on the screen?

PaigeMiller
Diamond | Level 26

But for some reason that did not work:

 

What do you mean? What doesn't work? Please be specific and detailed. Is the macro still available and used by the program when you expect it should not longer be available? Or do you mean something else?

 

If a macro is defined and available to the program because you have executed the macro code earlier in the program, then commenting out the macro does not change the fact that the macro is still available to the program.

 

 

--
Paige Miller
ballardw
Super User

If you start a comment with /* you should end it with */ to make a "block comment".

If you do not use the */ then it appears in your case the comment used the * <text until the first>; line comment.

And your second /* compounds the not correct usage.

Either use /* */ or know that * ; defines start / end of comment. Inside a macro definition you want to use /* */ or %* ; to comment as the macro language processor may treat *; style comments as valid code submitted to code processor.

 

Note that nesting /* /* type comment starts can lead to unstable code as the IDE is not set up to handle figuring how to "unnest"  or end the comments properly.

 

Quentin
Super User

/*  */ will definitely comment out a macro definition, macro call, or anything else (except a nested /* */ ).

 

It doesn't matter if you write the code in a text editor or in EG.

 

The coloring shown in EG is sometimes wrong, because EG has simple rules for trying to guess if code is a comment or not.  But the coloring of the code does not have any impact on how the code executes.  EG is just trying to be helpful to the person looking at EG screen.  When the code is sent to SAS to execute, coloring of the code is not sent to SAS.

 

If you are getting errors, they are likely coming from some other part of your code you haven't shown.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1083 views
  • 0 likes
  • 5 in conversation