BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
LineMoon
Lapis Lazuli | Level 10

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;

1 ACCEPTED SOLUTION

Accepted Solutions
arodriguez
Lapis Lazuli | Level 10

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

6 REPLIES 6
arodriguez
Lapis Lazuli | Level 10

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

Kurt_Bremser
Super User

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.

AmitRathore
Obsidian | Level 7

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;

jakarman
Barite | Level 11

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 --<-----
LineMoon
Lapis Lazuli | Level 10

Thank you for message.

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

jakarman
Barite | Level 11

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 --<-----

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!

How to Concatenate Values

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.

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
  • 6 replies
  • 1785 views
  • 8 likes
  • 5 in conversation