BookmarkSubscribeRSS Feed
SAS_INFO
Quartz | Level 8

Hello,

 

I have a code, that executes multiple codes based on the code frequency.

For example,

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.

 

Sample Code:

 


libname test  "/data/DEV/SYS";

%let RUNDATE = &SYSDATE9;
%put &rundate.;

%put %sysfunc(weekday("&RUNDATE."d));
%put %sysfunc(day("&RUNDATE."d));

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;

  %include "&file_path./&file_name.";
  %put "&frequency.";
  %put "&file_path./&file_name.";

  data results;
   set results test.&output_file. (keep= Name Description Country State);
  run;
 %end;
%mend run_code;

data results;
 set _NULL_;
run;

data _NULL_;
 set test.rule_input;
 call execute ('%run_code('||TRIM(Frequency)||','||TRIM(SASFILE)||','||TRIM(output_file)||')');
run;

proc format;
picture date_b_fmt(default=45)
low-high='%Y-%0m-%0d %0H:%0M:%0S'(datatype=datetime);
run;

data test.ALLCust_&RUNDATE.;
set results;
format run_date date_b_fmt.;
format rundate1 date9.;
Run_date=datetime();
Rundate1=today();
run;

 

/*END OF CODE*/

4 REPLIES 4
SASKiwi
PROC Star

I'm guessing that your code is running with the SAS option SYNTAXCHECK. Trying NOSYNTAXCHECK may give you the behaviour you want.

 

http://documentation.sas.com/?docsetId=lesysoptsref&docsetTarget=n014qbvh3po8w5n1qlqbzr22vtg0.htm&do...

 

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.

SAS_INFO
Quartz | Level 8

hi SASKIWI.

 

thank you for the reply.

 

can u guide be about the scheduling tools,

 

Regards,

Aruna B

SASKiwi
PROC Star

The SAS Scheduling guide is a good place to start:

 

http://documentation.sas.com/?docsetId=scheduleug&docsetTarget=n1c1fie1vigujin12wrepb4kdq87.htm&docs...

 

I would also check with your IT folks regarding any tools used currently.

SAS_INFO
Quartz | Level 8

 Hi All,

 

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.

 

Regards,

Ar

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 4 replies
  • 895 views
  • 0 likes
  • 2 in conversation