02-03-2015 04:21 AM
Message was edited by: xia keshan
02-03-2015 04:23 AM
SAS works with 2 steps(or PHASES).
In the first step known as COMPILATION PHASE, your code is parsed. If anything unknown to SAS in this step is detected and the Compilation stops the program throwing what it found in the LOG window. In this step, logical errors, mis-spelling of names of function names, missing of key words will be picked up. This is the step where many of your mistakes will be found. But still there remain other errors of coding in the code, such as wrong assignments, loop-evaluations etc. The second type of errors can be found by running the program(EXECUTION PHASE) statement by statement by the use of Data Step DEBUGGER. It will be placed after the first statement of your program like:
02-03-2015 04:28 AM
Well, until the code passes through the pre-processor you are not going to have full code. This part of the process derives all your macro information and expands the code per macros. Once that is done the full code is then sent to the compiler which parses the code into machine readable (or compiles it). There is no checker as far as I am aware. You can pre-check SQL code by using the noexec in the proc sql statement. This checks the SQL but does not execute it. I don't know of anything similar for SAS. You can check for most issues just by looking at the colors in the Enhanced Editor (its why its different colors), for instance text strings not finished with same quote. You could in theory build a text parse program to do checking, but why would you want to? Your not building enterprise applications so the code is generally small and reasonably basic, and the compiler is already there to do the checking for you. Just run it bit by bit interactively. Also options like mprint symbolgen mlogic, and using %put statements help with debugging.
If you have a specific requirement, perhaps post an example?
02-03-2015 10:46 AM
One simple thing if you are checking for syntax not logic in a datastep: Use RUN Cancel; which will not execute the code but the SAS compiler will run a syntax check.