Hi,
I've heard for the first time during a SAS Institute webinar that no semi-column should be used after a macro call. The reason is that it would occasionally create a bug. I've programmed over 20 years in SAS using a semi-column without encountering any issue. Do you know about more about this rule? Was it always the case? Do you have an example of issue?
Kind Regards,
See this:
%macro datasets;
%do y = 2000 %to 2021;
ds_&y.
%end;
%mend;
data want;
set
%datasets; /* this semicolon causes trouble */
indsname=ds
;
dsname = ds;
run;
I have heard this, and I never use a semi-colon after a macro call.
However, I cannot provide an example where the semi-colon after the macro call causes a problem.
The rule is that you cannot insert a sem-colon into the middle of a statement.
But extra semi-colons between statements normally does not cause any trouble (which is probably why you have not had any issues).
So if the macro generates only part of statement (some times call macro functions) then adding a semi-colon after the macro function call would insert the semi-colon into the middle of the statement.
See this:
%macro datasets;
%do y = 2000 %to 2021;
ds_&y.
%end;
%mend;
data want;
set
%datasets; /* this semicolon causes trouble */
indsname=ds
;
dsname = ds;
run;
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.