Pages

Monday, August 5, 2013

Widgets

Syntax Checking SAS Programs

To check the syntax of a data step or procedure without actually running the code, add a CANCEL keyword to the end of the RUN statement, as shown in the following example:
data work.test;
infile 'external file';
input a b c;
run cancel;
proc print data=work.test;
run cancel;
Each step will validate the "tokens" in your syntax and report any errors to the SAS log. SAS will then stop processing that step, therefore no data are read.
Commonly, a macro variable is created that is resolved in place of the CANCEL keyword. This allows a global method of turning syntax checking on or off. This is demonstrated with the following example:
%let debug=CANCEL;
%*let debug=;
data work.test;
infile 'external file';
input a b c;
run &debug.;
proc print data=work.test;
run &debug.;

No comments:

Post a Comment