Comment Statement

Specifies the purpose of the statement or program.
Valid in: Anywhere
Category: Log Control

Syntax

or

Arguments

*message;
specifies the text that explains or documents the statement or program.
Range:These comments can be any length and are terminated with a semicolon.
Restrictions:These comments must be written as separate statements.

These comments cannot contain internal semicolons.

A macro statement or macro variable reference that is contained inside this form of comment is processed by the SAS macro facility. This form of comment cannot be used to hide text from the SAS macro facility.

Tip:When using comments within a macro definition or to hide text from the SAS macro facility, use this style comment:
   /* message */
/*message*/
specifies the text that explains or documents the statement or program.
Range:These comments can be any length.
Restriction:This type of comment cannot be nested.
Windows specifics: If you use the Enhanced Editor, you can comment out a block of code by highlighting the block and then pressing CTRL-/ (forward slash). To uncomment a block of code, highlight the block and press CTRL-SHIFT-/ (forward slash).
Tips:These comments can contain semicolons and unmatched quotation marks.

You can write these comments within statements or anywhere a single blank can appear in your SAS code.

Details

You can use the comment statement anywhere in a SAS program to document the purpose of the program, explain unusual segments of the program, or describe steps in a complex program or calculation. SAS ignores text in comment statements during processing.
CAUTION:
Avoid placing the /* comment symbols in columns 1 and 2.
In some operating environments, SAS might interpret a /* in columns 1 and 2 as a request to end the SAS program or session.
Note: You can add these lines to your code to fix unmatched comment tags, unmatched quotation marks, and missing semicolons.
/* '; * "; */; 
quit; 
run;

Example: Using the Comment Statement

These examples illustrate the two types of comments:
  • This example uses the *message; format:
    *This code finds the number in the BY group;
  • This example uses the *message; format:
       *---------------------------------------*
       |  This uses one comment statement      |
       |           to draw a box.              |
       *---------------------------------------*;
  • This example uses the /*message*/ format:
     input @1 name $20.  /* last name    */
           @200 test 8.  /* score test   */
           @50 age 3.;   /* customer age */
  • This example uses the /*message*/ format:
       /* For example 1 use: x=abc; 
          for example 2 use: y=ghi; */