Learning SAS? Welcome to the exclusive online community for all SAS learners.

Understanding Asterisk Comments in a Macro

Reply
Occasional Contributor
Posts: 9

Understanding Asterisk Comments in a Macro

Can someone explain why the macro %DOIT

 

%macro abc;
   *%put in abc;  
%mend abc;

%macro doit;
   *%abc  
   %put here;
   *%let x = %abc; 
   %put value of x is &x;
%mend doit;
%doit   * run doit;  

yields this?

 here
 in abc
 value of x is *

Why is the first call to %ABC is commented, while the %PUT and %LET statements aren't?

 

Super Contributor
Posts: 252

Re: Understanding Asterisk Comments in a Macro

Posted in reply to rararayayayay

I don't know. It's always confused me and it always stuffs things up. That's why I use '/* … */' for my macro comments. And when I need to comment them out, because they don't cascade, I put 

 

%macro comment;
…
…
%mend comment;

 

around blocks of code.

 

I know it doesn't answer your question, which is a good one, but sometimes life's too short.

Super User
Posts: 7,758

Re: Understanding Asterisk Comments in a Macro

Posted in reply to rararayayayay

Looks to me like Macro calls are not executed in an asterisk style comment, but macro statements are executed. As the second macro call is part of a macro statement (%let), it is executed and yields a single asterisk.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 2 replies
  • 152 views
  • 2 likes
  • 3 in conversation