BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

I've 5 data steps. If I execute and if there is a WARNING in the first step, I do not want the other steps to execute. Is there a way to achieve this?

2 REPLIES 2
s_lassen
Meteorite | Level 14

The easiest way is to check the SYSCC automatic macro variable. This variables has two advantages:

  1. You can set it
  2. It shows the maximum error or warning code since you set it:
%let SYSCC=0;

Data x; 
/*  this is your first data step */
run;

data _null_;
  if &syscc then abort cancel file;
run;

I used the CANCEL FILE version of the ABORT statement, as this will not terminate your SAS session if you are testing in oline SAS.

If you only want to exit on errors, you should check for SYSCC>4, 1 to 4 are warnings.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

The question should really be, why does the datastep cause errors/warnings?  First off, a warning may not fail the following steps, that is a key difference between warning and error.  Second, you should be coding "in a defensive manner".  What this means is pre-empting and handling issues, if code is throwing errors/warnings later on and your input hasn't changed (as it wont as you will have an import agreement/import process), then the code was not correctly coded first time.  Proper testing and robust coding will avoid these issues.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3995 views
  • 2 likes
  • 3 in conversation