How do I create comments in SAS?

Comments in SAS can be created by using a double slash (//) at the beginning of the line or by using /* */ around multiple lines. Comments are an essential programming practice, as they help to document the code and explain its intention. Comments also make it easier for others to understand the code.


The easiest way to create a comment in SAS is to highlight the text and press Ctrl + /.

You can just as easily remove the comment by highlighting the text again and pressing Ctrl + /.

If you would rather create a comment manually, you can also type /* at the beginning of the text and then type */ at the end of the text you’d like to turn into a comment.

The following example shows how to do this in practice.

Example: Create Comments in SAS

Suppose we have the following code in SAS:

The first four lines of the code simply describe what the rest of the code does.

Thus, we want to turn these lines into comments.

To turn the first four lines into comments, we can highlight each of the first four rows and press Ctrl + /:

create comments in SAS

Notice that a forward slash with an asterisk (/*) has been added to the beginning of each line and an asterisk and a forward slash (*/) have been added to the end of each line.

This indicates that those four lines are comments.

We can just as easily uncomment the first four lines by highlighting each line and pressing Ctrl + / once again:

uncomment code in SAS

Note that the forward slashes and asterisks have been removed from each of the first four lines.

This indicates that each line is no longer a comment.

The following tutorials explain how to perform other common operations in SAS:

x