• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • VBA
  • About
You are here: Home / SAS / SAS Comments – Commenting Your SAS Code the Right Way

SAS Comments – Commenting Your SAS Code the Right Way

January 19, 2022 Leave a Comment

When writing programs in any programming language, comments can be useful to add further context to the code. In SAS, there are a few ways you can comment code in your programs.

*This is a comment;
%*This is a second comment;
/*This is a third comment*/
/*This is a fourth multi-line
comment*/

There are three main ways you can add comments to your SAS code.

The first is to start with an asterisk and end with a semicolon.

*This is a comment;

The second way to add SAS comments is to start with an percent sign and asterisk, and end with a semicolon.

%*This is a comment;

The last way is to start with a forward slash and asterisk and end with an asterisk and forward slash.

/*This is a comment*/

How to Create Multiline Comments in SAS

Many times when we are programming, it is not enough just to add a single line comment to explain or describe what is going on in the code.

For example, when creating a file, best practices are that we should add a header which may include filename, date, author, description, etc.

In this case, you could use single line comments for each line, but something more useful is to use multiline comments in SAS with the /* */ way of creating a SAS comment.

Below are two ways you can do multiline commenting in your SAS code.

*The single line comment way:;
*This is a article about SAS comments;
*URL: http://theprogrammingexpert.com/sas-comments/;
*Author: The Programming Expert;

/* The multiline comment way:
This is a article about SAS comments
URL: http://theprogrammingexpert.com/sas-comments/
Author: The Programming Expert */

One trick is to use Ctrl-/ to comment out multiple lines of code in your SAS program. Just highlight what you want to comment out, and then press Ctrl-/.

If you were to type out your comments and then use Ctrl-/, the resulting SAS comment would look like:

/* The multiline comment way: */
/* This is a article about SAS comments */
/* URL: http://theprogrammingexpert.com/sas-comments/ */
/* Author: The Programming Expert */

Personally, I prefer to only use the second way in all of my SAS comments, but that is just personal preference. In my experience, it’s easier to toggle with Ctrl-/ than to worry about * and ;.

Hopefully this article has been useful for you to understand how to add comments to your SAS code.

Other Articles You'll Also Like:

  • 1.  Multiple Condition If Statements in SAS Macro Language
  • 2.  SAS Lowercase – Make String Lowercase with SAS lowcase function
  • 3.  SAS ceil – Round Up to Ceiling of Number in a SAS Data Step
  • 4.  SAS rand – Generate Random Numbers in a SAS Data Step
  • 5.  SAS Uppercase – Make String Letters Uppercase with SAS upcase function
  • 6.  SAS where in – Subset Data by Multiple Values in Data Step
  • 7.  SAS left() Function – Left Align Character Variables in Data Step
  • 8.  How to Combine Datasets Vertically in SAS
  • 9.  =">SAS Greater Than or Equal to with GE or >=
  • 10.  SAS floor – Round Down to Floor of Number in a SAS Data Step

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

The Programming Expert is a compilation of hundreds of code snippets to help you find solutions to your problems in Python, JavaScript, PHP, HTML, SAS, and more.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2022 · The Programming Expert · About · Privacy Policy