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;

The Boston Area SAS Users Group is hosting free webinars!
Next up: Rick Wicklin presents Ten Tips for Effective Statistical Graphics (with SAS code) on Wednesday March 26.
Register now at 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-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

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
  • 1580 views
  • 3 likes
  • 2 in conversation