BookmarkSubscribeRSS Feed
pope1970
Calcite | Level 5

I have this piece of code and it work perfectly

  %if (&job_rc eq 4) %then

  %do;

     %global email2;  

     %global error_desc2;  

      proc sql noprint;

       create table error_detail2 as

        select strip(recipient) as recipient,

               strip(error_description) as error_description

       from RISK.ERROR_.........

        where jobflow = 'DM_LOAD' and

              subject = 'Schema Error';

      quit;

      proc sql noprint;

        select strip(recipient) as recipient,

               strip(error_description) as error_description

        into :email2, :error_desc2

        from error_detail2;

      quit;

    %macro etls_sendEmail(message=);

      %let email2=&email2;

      %let error_desc2=&error_desc2;

         filename sendMail email "&email2"  subject='Load_ALL..... - Job ........ --- 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

       (Message = &error_desc2);

  %end;

and the output (Message part of email) look like below

08Jul14:10:49:39 ------ Target table column name changed (Oracle or DI) - Error

But now it is changed and I should display something like this

Error Date Time: 08Jul14:10:49:39  - Target table column name changed (Oracle or DI) - Error

Technical Team to advise

log file path: sas/log/......

I know that I have to modify this piece of code and add (concatenate) macro variable value &error_desc2 to &message, but it doesn't work...

         data _null_;

            file sendMail;

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

            put dttm "&message.";

         run

2 REPLIES 2
MikeFrost
SAS Employee

Hi,

This is definitely an issue you will want to open a track with SAS Technical Support to help you resolve.

Regards,

Mike F.

Patrick
Opal | Level 21

This looks to me like a usage problem so not something where you should raise a SAS Tech Support track. The code you've posted looks very close to auto generated one as part of job Status Handling but as there are a few differences I assume it's a copy and actually user written code - so you can change it as you wish. Below suggestion under the assumption it's user written:

You define a macro "%etls_sendEmail" with a parameter "message"

    %macro etls_sendEmail(message=);

        ......

        data _null_;

            file sendMail;

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

            put dttm "&message.";

        run;

        ......

    %mend etls_sendEmail;

You call macro "%etls_sendEmail" and pass value "&error_desc2" to the parameter. That is the value which gets written as email body.

    %etls_sendEmail

      (Message = &error_desc2);

You could change the code to something like:

    %macro etls_sendEmail(line1=,line2=,line3=);

        ......

        data _null_;

            file sendMail;

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

            put "Error Date Time: " dttm "&line1.";

            put "&line2.";

            put "&line3.";

        run;

        ......

    %mend etls_sendEmail;

    %etls_sendEmail

      (line1= &error_desc2,

        line2=Technical Team to advise,

        line3=log file path: <some macro var to define containing the path and log name>

      )

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 2087 views
  • 1 like
  • 3 in conversation