Programming Tips

Like other programming environments, SAS has rules of syntax to follow. Here are a few guidelines:
All SAS program statements must end with a semicolon ";"
Most SAS statements will begin with a SAS keyword (i.e. DATA, PROC, BY).
When reading data into a SAS dataset, SAS will recognize a period "." by itself as representing a missing value.

Comments are used to make your program easier to read and edit. SAS does not execute comment statements; in other words, they exist for the programmer only. They may also be used to "turn off" sections of your program. When SAS sees a comment in a program, it ignores it. All comments must be terminated.

There are two ways to write comments into your program:
  1. Put an asterisk "*" at the beginning of a line, write the comment, and terminate the comment with a semicolon:
    *This is a one-line comment;
  2. Start a block of comment lines with /*. Write as many comment lines as you want. Terminate the comment with */.
    /* This is
    a three line
    comment */
When you create names for the variables and SAS datasets to be used in your programs, you must follow the SAS naming rules: You must always end each SAS program with the RUN; statement.