Diagnosing and Avoiding Errors |
If you follow some basic guidelines as you develop a program, then you can avoid common errors. Use the following checklist to flag and correct common mistakes before you submit your program.
Check the syntax of your program. In particular, check the following:
All SAS statements end with a semicolon; be sure you have not omitted any semicolons or accidentally typed the wrong character.
Any starting and ending quotation marks must match; you can use either single or double quotation marks.
Most SAS statements begin with a SAS keyword. (Exceptions are assignment statements and sum statements.) Be sure you have not misspelled or omitted any of the keywords.
Every DO and SELECT statement must be followed by an END statement.
Check the order of your program. SAS usually executes the statements in a DATA step one by one, in the order they appear. After executing the DATA step, SAS moves to the next step and continues in the same fashion. Be sure that all the SAS statements appear in order so that SAS can execute them properly. For example, an INFILE statement, if used, must precede an INPUT statement.
Also, be sure to end steps with the RUN statement. This is especially important at the end of your program because the RUN statement causes the previous step to be executed.
Check your INPUT statement and your data. SAS classifies all variables as either character or numeric. The assignment in the INPUT statement as either character or numeric must correspond to the actual values of variables in your data. Also, SAS allows for list, column, formatted, or named input. The method of input that you specify in the INPUT statement must correspond with the actual arrangement of raw data.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.