This is not exactly a request for solutions, but an invitation for comments. Maybe someone has brought this to SAS' attention already.
The discussion starting out the documentation for %* Macro Comment Macro Statement is not being challenged here. Instead I am focusing on an example in this section intended to show that an ordinary comment statement (beginning with * or with COMMENT) does NOT mask the comment content from the macro processor (hence the need for /* */ or %*). It does show that property alright, but a little more pathologically than intended.
The example is as follows:
%macro verdata(in, thresh);
*%let thresh = 5;
/* The preceding SAS comment does not hide the %let statement
as does this type of SAS comment.
%let thresh = 6;
*/
%if %length(&in) > 0 %then %do;
%* infile given;
data check;
/* Jim's data */
infile ∈
input x y z;
* check data;
if x<&thresh or y<&thresh or z<&thresh then list;
run;
%end;
%else %put Error: No infile specified;
%mend verdata;
%verdata(ina, 0)
which the documentation asserts will produce this sas program:
DATA CHECK;
INFILE INA;
INPUT X Y Z;
* CHECK DATA;
IF X<5 OR Y<5 OR Z<5 THEN LIST;
RUN;
Nope. It actually produces this sas code:
* data check;
infile ina;
input x y z;
* check data;
if x<5 or y<5 or z<5 then list;
run;
... and a lot of error messages in the sas log.
This is ironic, since while successfully showing that the *%let thresh=5; causes macro processor to ignore the asterisk and assign a value of 5 to thresh, it also shows that the resulting %let macro statement absorbs the semicolon, thereby converting the subsequent data statement into a comment (pesky little asterisk left untouched by macro).
The latter consequence was overlooked in the documentation. I don't think the example was actually tested (also revealed by the fact that the purported resulting code is capitalized even though the source code inside the macro wasn't).
You are right.
Click on the Feedback link on that documentation page and report the issue to the documentation team. They are very happy to get constructive feedback like this.
You are right.
Click on the Feedback link on that documentation page and report the issue to the documentation team. They are very happy to get constructive feedback like this.
@Tom wrote:
You are right.
Click on the Feedback link on that documentation page and report the issue to the documentation team. They are very happy to get constructive feedback like this.
Done.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.