Jan 19, 2012

SAS Errors, Notes and Warnings

My take on general errors that a SAS developer need to watch out for...

Problem Symptom
missing RUN statement "PROC (or DATA) step running" at top of active window
missing semicolon log message indicating an error in a statement that seems to be valid
unbalanced quotation marks log message indicating that a quoted string has become too long or that a statement is ambiguous
invalid option log message indicating that an option is invalid or not recognized
Missing = after data= option on any proc step Gives an error in the log
*text; This commenting style creates problems within %macro and %mend
Commenting Style in Mainframe Avoid placing the /* comment symbols in columns 1 and 2. On Mainframe operating systems, SAS might interpret a /* in columns 1 and 2 as a request to end the SAS job or session. 
Formats length is small If a format is too small, the following message is written to the SAS log: "NOTE: At least one W.D format was too small for the number to be printed. The decimal may be shifted by the 'BEST' format."
Print Procedure Forgetting Label option on Proc Print
SQL/ Dataset Quit statement for Proc SQL
quotes in titles statement " Joan's Report"
merge statement No sort before merge
SQL/ Dataset alias in SQL
Tabulate / Means Class and Var statements  (char and Var statement)
  Invalid data type for data type numeric
  Inappropriate dataset and system options
  problems in Resolving Macros
  Append problems force option …datatype and lengths should be similar
  Automatic Num-Char or Char-Num conversion
  Proc format value statement errors char and numeric
  incorrect lengths - length statement type- logic errors
  Input statement /positions / informats/ missover / dsd/ dlm
putting a space after in the SAS Date constants data some; TestDate='01jan2000' d; run;
SQL Column Not available on the Table
  Datatype Mismatch in the Where Clause
  Use Feedback option when required to look at the SQL sent to the DBMS
Macro When the macro processor cannot resolve a macro variable reference, a message is printed in the SAS log. For example, referencing a nonexistent macro variable results in a warning message. 
  Referencing an invalid macro variable name results in an error message
To find… Do this for Resolution…
Undefined or misspelled keywords In the Appearance tab of the Enhanced Editor Options dialog box, set the file elements Defined keyword, User defined keyword, and the Undefined keyword to unique color combinations. When SAS recognizes a keyword, the keyword changes to the defined colors. You'll be able to easily spot undefined keywords by looking for the colors that you selected for undefined keywords.
Unmatched quoted strings Look for one or more lines of the program that are the same color. Text following a quotation mark remains the same color until the string is closed with a matching quotation mark.
Unmatched comments Look for one or more lines of the program that are the same color. Text that follows an open comment symbol ( /* ) remains the same color until the comment is closed with a closing comment symbol ( */).
Matching DO-END pairs Place the cursor within a DO-END block and press Alt+[. The cursor moves first to the DO keyword. If one of the keywords is not found, the cursor remains as positioned. When both of the keywords exist, pressing Alt+[ moves the cursor between the DO-END keywords.
Matching parentheses or brackets Place the cursor on either side of the parenthesis or bracket. Press Ctrl+]. The cursor moves to the matching parentheses or bracket. If one is not found, the cursor remains as positioned.
Missing semi-colons ( ; ) Look for keywords that appear in normal text.

Other Interesting Articles

The top 10 SAS Errors, Notes and Warnings that SAS Tech Support gets Calls for

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.