10-12-2017 08:18 PM
I have a code, that executes multiple codes based on the code frequency.
if the code "A" frequency is daily, then it will be executed Daily
If code "B" frequency is weekly then it will be executed weekly.
There are 12 codes, out of which
Daily - 5
Weekly - 4
Monthly - 3
My current situation is, if there is one code fails, then SAS stops executing the rest of the code.
I want to change it, so that even if one rule fails, SAS should execute the rest of the code and produce output , and a notification should be sent informing which code failed.
libname test "/data/DEV/SYS";
%let RUNDATE = &SYSDATE9;
PROC PRINTTO LOG=LOG; RUN;
%macro run_code(frequency, file_name, output_file);
%let file_path = /data/DEV/SYS/CODE;
%if ("&frequency." = "Daily")
or ("&frequency." = "Weekly" and %sysfunc(weekday("&RUNDATE."d))=1)
or ("&frequency" = "Monthly" and %sysfunc(day("&RUNDATE."d))=6) %then %do;
set results test.&output_file. (keep= Name Description Country State);
call execute ('%run_code('||TRIM(Frequency)||','||TRIM(SASFILE)||','||TRIM(output_file)||')');
format run_date date_b_fmt.;
format rundate1 date9.;
/*END OF CODE*/
10-12-2017 09:06 PM
I'm guessing that your code is running with the SAS option SYNTAXCHECK. Trying NOSYNTAXCHECK may give you the behaviour you want.
Rather than controlling your SAS programs using SAS, using a scheduling tool would allow you to have better control as well as automatically emailing if there is a problem.
10-12-2017 10:03 PM
The SAS Scheduling guide is a good place to start:
I would also check with your IT folks regarding any tools used currently.
10-12-2017 11:32 PM
The viable option is to schedule the code individually, so that one code failure will not affect the others.
Moving on to the next request, Once all the codes are executed, all their output datasets needs to get appended to one dataset.
Now, the same scenario, if any one of the output is not available the entire appending will not work, I need a solution so that even any one or two output dataset is not available, the other output datasets should get appended.