BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
colinbarker2
Calcite | Level 5

So I would like a macro that upon finding the first error when running a project to stop all processes downstream and immediately print an external log. So far I have used the macro that looks like this 

%macro check_for_errors;
   %if &syserr > 0 %then %do;
      endsas;
   %end;
%mend check_for_errors;

data test1;
    <data step code>
run;
%check_for_errors;

 Currently it will continue with further process the downstream items and include that in the external log. I would like it to after it encounters that first error to stop it and have that error be the last thing it prints to the external log to make debugging easier. 

Note: I also have in the project property settings to stop all items on errors during execution.

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

If you are only running SAS code, then it would be a whole lot easier to run the program in batch mode with the ERRORABEND option set (Add options errorabend; as the first statement in the rpiogram). No checking for errors is required and a SAS log is produced and the program will stop running when the first error is encountered.

View solution in original post

2 REPLIES 2
Quentin
Super User

I'm confused, I would think ENDSAS would end the session immediately and get what you want.

 

Can you share the log you get when there is an error?

 

You might also want to look into the ABORT statement as an alternative to ENDSAS.

 

 

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
SASKiwi
PROC Star

If you are only running SAS code, then it would be a whole lot easier to run the program in batch mode with the ERRORABEND option set (Add options errorabend; as the first statement in the rpiogram). No checking for errors is required and a SAS log is produced and the program will stop running when the first error is encountered.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 318 views
  • 1 like
  • 3 in conversation