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.

BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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