The semicolons are not necessary for macro calls.
They are often included, as people are accustomed to seeing semicolons as a way to “terminate a statement” or end a line. I personally prefer to include them whenever possible, because I think this makes my code more readable.
Remember that macros simply evaluate themselves and return what they resolve to, which may be a block of code that looks like a number, a string, or something else ...
Take this example where the semicolon is not used:
%macro field_list(); name, age, sex, height %mend; proc sql; select %field_list() from sashelp.class ; quit;
Try running it on your machine with option mprint; . The result of running a macro simply returns a block of code inside it. This leads to the execution of the following code:
proc sql; select name, age, sex, height from sashelp.class ; quit;
If after calling our macro we had a semicolon, then the code that SAS tries to run would include a semicolon, which would be invalid syntax (note the semicolon after the height):
proc sql; select name, age, sex, height ; from sashelp.class ; quit;
This is due to the fact that a semicolon is NOT required to call macros, so it simply remains left and is included in the execution of the stage.
When you call a macro, as you do in the example you give above, it should contain a semicolon, because your macro is a completely autonomous step. And in open source, there is no harm having extraneous semicolons, for example:
%macro example2(inDS=, outDs=); data &outDs; set &inDs; run; %mend; %example2(inDS=sashelp.class, outDs=tmp_class);
This basically means:
data tmp_class; set sashelp.class; run;;
Pay attention to the extra semicolon at the end to the left of our call? We could have as much as we wanted, and the code would still work fine, i.e.
%example2(inDS=sashelp.class, outDs=tmp_class);;;;;;
Allows:
data tmp_class; set sashelp.class; run;;;;;;;
Which will still work fine, since this is a valid syntax.