1

This code will be part of process in SAS data Integration Studio.

I want to achieve something like:

%macro conditional_start();

%let check_condition = 0;

%if check_condition eq 0 %then %do;

    %send_email_that_condition_has_been_met(); /* this I have made */

    /*Below run some kind of built-in macro probably, to stop execution of the whole code below */


%end;

%mend;

/*More macros end code I don't want to execute*/

I cannot pack everything below in big "if" statement because they are built in blocks.

Is it possible?

Thanks in advance!!

Mateusz Konopelski
  • 1,000
  • 4
  • 20
  • 37
  • Show more the code that occurs after your `conditional_start` macro definition. When does conditional_start get invoked ?. Does the un-shown code contain macro definitions and invocations, only open code or a mixture ? Is `conditional_start` invoked from inside another macro ? – Richard Mar 12 '19 at 08:57
  • `conditional_start` macro stars as first transformation in the SAS DI job. Afterwards is mixture of open-code and definitions and macros. The idea was to build a custom transformation in SAS DI - to execute always as first one and check if certain conditions of input tables are met and if no set macro variable `check_condition` to 0 and do not execute the entire job. – Mateusz Konopelski Mar 12 '19 at 10:37
  • Alternatively, I was thinking whether I could use "Conditional Start" built in transformation as second step to check if `check_condition ne 0` - If I understand it correctly in such case the entire job would not execute because this condition would not be met. – Mateusz Konopelski Mar 12 '19 at 10:41
  • With out changing something after conditional start, I don't think you can prevent what comes after it and having execution go into a ready state. You can try to stop the current execution with an `%ABORT CANCEL;` in the macro, but what that eventually does depends on how the macro is invoked by Studio. – Richard Mar 12 '19 at 10:43
  • Yes, whenever possible work within known operating environment rather than foist some conditions into it. – Richard Mar 12 '19 at 10:46
  • Possible duplicate of [Stop SAS Program on Error](https://stackoverflow.com/questions/9470248/stop-sas-program-on-error) – user667489 Mar 13 '19 at 13:47
  • @user667489 while %abort might be useful macro, itis not what I am looking for. – Mateusz Konopelski Mar 13 '19 at 22:08

1 Answers1

1

Have you tried to put your code into "precode" (leave macro open) and "postcode" (rest of the macro) sections of your job's properties? For example:

precode:

%macro the_whole_job();

postcode:

%mend the_whole_job;

%macro conditional_start();
    %let check_condition = 0;
    %if check_condition eq 0 %then %do;
         %send_email_that_condition_has_been_met(); /* this You have made */
         /*do some kind of built-in macro meaning failure, not executing the whole code above*/
    %end;
    %else %do;
         %the_whole_job;
    %end; 
%mend;