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.

 

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at 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 2025: Call for Content

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!

Submit your idea!

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
  • 522 views
  • 1 like
  • 3 in conversation