stopping the sas execution after the first error or warning

Accepted Solution Solved
Reply
Super Contributor
Posts: 371
Accepted Solution

stopping the sas execution after the first error or warning

I want to stop the sas execution after the first error and keeping the log.

sas can show me the location of error in sas code( I am not talking about the log, I know that in the log, we will see the error).

I want to know, If i can have some thing likes this:

data test;

set t1 t2

run;

in program, I can see some thing likes this ?

   data test;

   ==>   set t1 t2

run;


Accepted Solutions
Solution
‎06-30-2015 02:04 AM
Frequent Contributor
Posts: 144

Re: stopping the sas execution after the first error or warning

Hi LineMoon,

If it is in a macro language, you could define a macro variable that contain the information if there is any error, and if there are any error do something like this

%if &status=0 %then %return;

This will stop the execution of the program

View solution in original post


All Replies
Solution
‎06-30-2015 02:04 AM
Frequent Contributor
Posts: 144

Re: stopping the sas execution after the first error or warning

Hi LineMoon,

If it is in a macro language, you could define a macro variable that contain the information if there is any error, and if there are any error do something like this

%if &status=0 %then %return;

This will stop the execution of the program

Esteemed Advisor
Posts: 6,661

Re: stopping the sas execution after the first error or warning

Best is to create a macro that checks the relevant automatic macro vars and jumps to a label at the end of the code if an error/warning condition is detected; insert that macro after every step.

The ERRORABEND option will only check errors, not warnings, and terminate the process, which is only good for batch jobs.

For easier detection of syntax errors, SAS provides the enhanced editor and its color scheme; for errors happening at runtime, look at the log.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 21

Re: stopping the sas execution after the first error or warning

Hi Kurt, Thanks for suggesting this options. It solves many of my problems also. Smiley Happy

Hey LineMoon, below is the code for your reference :

options ERRORABEND;

data t1;

  x = 1; y = 'a'; output;

  x = 2; y = 'b'; output;

  x = 3; y = 'c'; output;

run;

data t2;

  x = 4; z = 'a'; output

  x = 5; z = 'b'; output;

  x = 6; z = 'c'; output;

run;

proc sql noprint;

  create table t3 as

  select * from t1

  outer union corr

  select * from t2;

quit;

Valued Guide
Posts: 3,206

Re: stopping the sas execution after the first error or warning

The option errorabend or better syntaxcheck mode is the default for batch processes.

For interactive mode a human is expected to react. That is why sas has chosen to continue as much as possible.

Do not use the option errorabend in a sas bi environment as cit could lose necessary informstion and sessions.

There are whole documented chapters on configuring error handling as it more complex as suspected.

---->-- ja karman --<-----
Super Contributor
Posts: 371

Re: stopping the sas execution after the first error or warning

Thank you for message.

Please can you explain more "a sas bi environment as cit "

Valued Guide
Posts: 3,206

Re: stopping the sas execution after the first error or warning

The classic sas DMS is connected to a terminal or running on your desktop.

It is based on having some source (input) getting results (output) and a log file. It is the approach of batch processing with punch cards in the 60's.

With Sas bi/di there is a metadata server object and more. It is more Iike a dbms system wit a data and system dictionary. All new solutions are based on that. Sas studio and Eguide server based. You can have more and shared sessions with those. Eguide studio sare sending the results and log after processing. Not terminal  based anymore. You will break that with an abort.

---->-- ja karman --<-----
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 299 views
  • 8 likes
  • 5 in conversation