SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Aborting a Job on certain errors

Posts: 28

Aborting a Job on certain errors



I want to run to abort a DI job on certain errors. I'm reading files stored in a location, and if the file doesn't exist, I'd like to abort the job and not run further steps. . I've got the aborting working for any errors encountered, but is there anyway to restrict it to just abort if it sees, ERROR: Physical file does not exist. I'm using the Return Code Check transformation to status handle the file reader, so if there's anyways to do it throug that, it'd be preferable than through BASE SAS. 



Posts: 311

Re: Aborting a Job on certain errors

I'm not sure about the mechanism to abort, but you could use code to check for the existence of a file (which is the error you're getting) and then conditionally execute other code inside a macro only if the file is found. Some code I've used is shown below.


%macro check_for_file(dir); 

   %local rc fileref;
   %global file_found_flag;
   %let rc = %sysfunc(filename(fileref, &dir));
   %put Checking for existence of &dir;
   %if %sysfunc(fexist(&fileref))  %then %let file_found_flag=1;    
   %else %let file_found_flag=0;

%mend check_for_file;

%macro x(file);


%if &file_found_flag = 1 %then %do;

%put The file exists. Run code...;

%else %do;

    %put The file was not found.;

%mend x;
Super User
Posts: 5,853

Re: Aborting a Job on certain errors

The functionality you're asking for is standard in most scheduling software. Use that, and shouldn't need to handle this in SAS at all.
Data never sleeps
Super User
Posts: 3,866

Re: Aborting a Job on certain errors

I prefer using general SAS options for SAS error checking and / or scheduler options as they are a lot easier and cope with most problems. The one I find most useful is the SAS option SYNTAXCHECK:


With this option whenever SAS hits a significant error it goes into syntax check mode and doesn't process any data.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation