COMMENT is a statement like any other submitted statement. In essence it is the same as * because the comment statement ends at the first semi-colon (;). The documentation does not specifically state * is an alias for COMMENT, but lists * ... ; and /* ... */.
Another way to comment multiple statements that also contain comment blocks is to nest the code inside a macro definition.
Example:
proc print data=sashelp.class;
run;
%macro MY_COMMENT;
* This part contains more statements;
proc print sashelp.cars;
run;
/* And there are comments in both styles of commenting */
%* But inside an uncalled macro everything acts like a giant comment block;
%mend MY_COMMENT;
* return to normal processing;
For very large blocks of commented code, during development of code, I will often wrap the commented part with NOSOURCE and SOURCE to prevent log clogging.
...
options NOSOURCE;
/*
Big chunk commented out during development to temporarily prevent
rerunning ETL process steps or regenerating already OK reporting code
*/
options SOURCE;
* work on new additional part of process flow here;
...
Other commenting tricks
Way 1 - /**/ pairs
If code is consistently commented with only *; style comments, then code blocks can be easily commented and uncommented using an introductory /**/ or /** / and a closing /**/ .
Uncommented - the intro is a plain comment
/**/ * some code here; /**/
Commented - the extra space in the intro causes the comment to be closed by the final */
/** / * some code here; /**/
Way 2 - /* *; */; toggle
Requires a *; comment as the first line of the block, and no /* */ comments within.
Toggle off, block code is commented out
/*
*intro;
... block ...
*/;
versus
Toggle on, block code is not commented out
*/*
*intro;
... block ...
*/;
Enhanced editor
- Comment
- Select a block of lines and press
Ctrl-/.
All the lines will become individual /*original line*/ style comment blocks.
- Uncomment
- Select a block of lines and press
Ctrl-Shift-/.
The leading /* and trailing */ of each line will be removed.
Macro variable
Use a flag variable with value or * as a statement introductory to enable or disable statements.
%if %sysget(USERNAME)=Richard %then %do;
%let flag=*;
%end;
%else %do;
%let flag=;
%end;
&flag. PROC PRINT ...;
&flag. ...;
&flag. ...;
&flag. run;