04-13-2017 07:56 AM
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.
04-14-2017 08:58 AM
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); %check_for_file(&file) %if &file_found_flag = 1 %then %do; %put The file exists. Run code...; %end; %else %do; %put The file was not found.; %end; %mend x; %x(yourPath\yourFile)
04-15-2017 08:17 PM
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.