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;
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
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
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.
Hi Kurt, Thanks for suggesting this options. It solves many of my problems also.
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;
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.
Thank you for message.
Please can you explain more "a sas bi environment as cit "
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.