BookmarkSubscribeRSS Feed
pope1970
Calcite | Level 5

I slightly modified the default status code for Job and copy/paste in Job Properties - PostCode.

So, the code work if succesfull    => &job_rc eq 0

and if I have hard coded email address

         (address = tod.smith@.....com,

          Message = ------ Syntax not correct - Error);

But if I have error     => &job_rc eq 3

but if I have variable for email address then it doesn't work...

         (address = &&email1,

          Message = ------ Syntax not correct - Error);

Here is the original code

%macro etls_jobRCChk;

   %if (&job_rc eq 3) %then

   %do;

      %macro etls_sendEmail(address=, message=);

     proc sql noprint;

    create table error_detail as

      select strip(t2.recipient) as recipient

      from RISK.ERROR_CONTROL t2

       where t2.jobflow = 'DM_LOAD' and

             t2.subject = 'Syntax Error';

    quit;

    proc sql noprint;

      select recipient

   into :email1

  from error_detail;

    quit;

        filename sendMail email "&address" subject='Load_ALL_STAGING - Job Load_STG_MTM_AUDIT --- Error';

     

         %local etls_syntaxcheck;

         %let etls_syntaxcheck = %sysfunc(getoption(syntaxcheck));

         options nosyntaxcheck;

     

         data _null_;

            file sendMail;

            dttm = put(datetime(),nldatm.);

            put dttm "&message.";

         run;

     

         options &etls_syntaxcheck;

      %mend etls_sendEmail;

      %etls_sendEmail

         (address = &&email1,

          Message = ------ Syntax not correct - Error);

  %end;

%mend etls_jobRCChk;

%etls_jobRCChk;

2 REPLIES 2
Quentin
Super User

Hi,

Can you add options MPRINT at the top, and then show the log you get which includes the error message?

It looks like you are trying to pass macro variable &email1 in the macro call, but that macro variable hasn't been created yet!  So maybe just skipping that will help.

Below suggest some style changes (particularly to avoid defining a macro inside another macro definition) and added debugging as well:

    options mprint;

     %macro etls_sendEmail(message=);

    %local email1;

     proc sql noprint;

      select strip(t2.recipient)  into: email1

      from RISK.ERROR_CONTROL t2

       where t2.jobflow = 'DM_LOAD' and

             t2.subject = 'Syntax Error';

    quit;

    %*above will return only one value from email1, so if could have multiple email addresses, would need to add separated by() above and pass list of email addresses to below;

   

    %put email1=&email1;

        filename sendMail email "&email1" subject='Load_ALL_STAGING - Job Load_STG_MTM_AUDIT --- Error';

    

         %local etls_syntaxcheck;

         %let etls_syntaxcheck = %sysfunc(getoption(syntaxcheck));

         options nosyntaxcheck;

    

         data _null_;

            file sendMail;

            dttm = put(datetime(),nldatm.);

            put dttm "&message.";

         run;

    

         options &etls_syntaxcheck;

      %mend etls_sendEmail;

    

%macro etls_jobRCChk;

   %if (&job_rc eq 3) %then

   %do;

     %etls_sendEmail

         (Message = ------ Syntax not correct - Error)

  %end;

%mend etls_jobRCChk;

%etls_jobRCChk;

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
pope1970
Calcite | Level 5

Hi Quentin

Your answer helped me to identify error and the error is

ERROR: Email address ddddd.ccccc@rrrrrrrr.com                                                                                 

                                                                                                                                   

                            too long. 256 character limit.

NOTE: The SAS System stopped processing this step because of errors.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1232 views
  • 3 likes
  • 2 in conversation