BookmarkSubscribeRSS Feed
PriyaSaha
Calcite | Level 5


Without executing SAS dataset or any records can we check error in the sas program?

how can we debug sas program ?

Thanks,

Priya

4 REPLIES 4
Ksharp
Super User

set option:

options obs=0;

data want;

   set have;

   temp_var=cats('t01',tel_1,'t02',tel_2,'t03',tel_3,'t04',tel_4,'t05',tel_5);

run;

Xia Keshan

Message was edited by: xia keshan

KachiM
Rhodochrosite | Level 12

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:

data want/debug;

......

........

run;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3917 views
  • 0 likes
  • 5 in conversation