<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Data Integration Studio - e-mail with log in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Integration-Studio-e-mail-with-log/m-p/793450#M254334</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm an inexperienced user of SAS Data Integration Studio.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would like to receive an e-mail information about the job status. Using "&lt;EM&gt;Status Handling&lt;/EM&gt;" and action "&lt;EM&gt;Send Email&lt;/EM&gt;" (from job options) is not satisfying to me. First of all - (propably?) i can't attach log to this e-mail (maybe there is another option for this job?).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In SAS Enterprise Guide I developed and tested code for sending email with log in attach and some useful informations (datetime, list of errors) in mail body:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%let mail = "test@test.com";
%let path_error = /home/ ... .log;

filename msg email
 to =           (&amp;amp;maile)
 subject =      "SAS Message Test"
 attach =       "&amp;amp;path_error.";

data _null_;
 dttm = put(datetime(),nldatm.);

 infile "&amp;amp;path_error.";
 input;

 file msg;
 if _n_ = 1 then do;
    put "Date time: " dttm;
    put;
    put "Full log in attach.";
    put "There are some ERRORs and WARNINGs:";
    put;
    end;
 if substr(_infile_,1,5) = "ERROR" then 
    put _infile_;
 if substr(_infile_,1,7) = "WARNING" then 
    put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code works fine - I get complete mail with list of errors and warnings. In log from Enterprise Guide I can see:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;NOTE: 268 records were read from the infile "[...].log"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But how to implement this code (especially reading by infile statement) in DIS?&lt;/P&gt;&lt;P&gt;I have modified the job options:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Precode - puts the log into an external file; log name contains jobname and datetime:&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;&lt;CODE&gt;%let path = /home/[...]/log_&amp;amp;etls_jobName._%sysfunc(datetime(), datetime.).log; 
proc printto log="&amp;amp;path.";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;OL&gt;&lt;LI&gt;Postcode - I used code from Enterprise Guide:&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;&lt;CODE&gt;%let address = "test@test.com";
%let message = problems with &amp;amp;etls_jobName;

         filename sendMail email 
                to=         (&amp;amp;address) 
                subject=        "ETL Process problem: &amp;amp;etls_jobName." 
                attach=     "&amp;amp;path."; 

            options nosyntaxcheck;  

         data _null_; 
            dttm = put(datetime(),nldatm.);

                infile "&amp;amp;path.";
                input;

                file sendMail; 
                 if _n_ = 1 then do;
                    put "Date time: " dttm;
                    put;
                    put "Full log in attach.";
                    put "There are some ERRORs and WARNINGs:";
                    put;
                    end;
                 if substr(_infile_,1,5) = "ERROR" then 
                    put _infile_;
                 if substr(_infile_,1,7) = "WARNING" then 
                    put _infile_;
         run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In effect I get e-mail with log in attach, but empty body. In attached log I can see:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;NOTE: 0 records were read from the infile &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've got some questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Why 0 records???&lt;/LI&gt;&lt;LI&gt;When I delete&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;input;&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;statement from Postcode and run job I get e-mail with "Date time / Full log in attach / There are some ERRORs and WARNINGs" in body. Why they are deleted where&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;input&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;works in code?&lt;/LI&gt;&lt;LI&gt;E-mail is not sending without&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;options nosyntaxcheck;&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in code. Why?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thanks for the answers. Regards, Michał&lt;/P&gt;</description>
    <pubDate>Mon, 31 Jan 2022 11:09:48 GMT</pubDate>
    <dc:creator>MichalRa</dc:creator>
    <dc:date>2022-01-31T11:09:48Z</dc:date>
    <item>
      <title>Data Integration Studio - e-mail with log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Integration-Studio-e-mail-with-log/m-p/793450#M254334</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm an inexperienced user of SAS Data Integration Studio.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would like to receive an e-mail information about the job status. Using "&lt;EM&gt;Status Handling&lt;/EM&gt;" and action "&lt;EM&gt;Send Email&lt;/EM&gt;" (from job options) is not satisfying to me. First of all - (propably?) i can't attach log to this e-mail (maybe there is another option for this job?).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In SAS Enterprise Guide I developed and tested code for sending email with log in attach and some useful informations (datetime, list of errors) in mail body:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%let mail = "test@test.com";
%let path_error = /home/ ... .log;

filename msg email
 to =           (&amp;amp;maile)
 subject =      "SAS Message Test"
 attach =       "&amp;amp;path_error.";

data _null_;
 dttm = put(datetime(),nldatm.);

 infile "&amp;amp;path_error.";
 input;

 file msg;
 if _n_ = 1 then do;
    put "Date time: " dttm;
    put;
    put "Full log in attach.";
    put "There are some ERRORs and WARNINGs:";
    put;
    end;
 if substr(_infile_,1,5) = "ERROR" then 
    put _infile_;
 if substr(_infile_,1,7) = "WARNING" then 
    put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This code works fine - I get complete mail with list of errors and warnings. In log from Enterprise Guide I can see:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;NOTE: 268 records were read from the infile "[...].log"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But how to implement this code (especially reading by infile statement) in DIS?&lt;/P&gt;&lt;P&gt;I have modified the job options:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Precode - puts the log into an external file; log name contains jobname and datetime:&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;&lt;CODE&gt;%let path = /home/[...]/log_&amp;amp;etls_jobName._%sysfunc(datetime(), datetime.).log; 
proc printto log="&amp;amp;path.";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;OL&gt;&lt;LI&gt;Postcode - I used code from Enterprise Guide:&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;&lt;CODE&gt;%let address = "test@test.com";
%let message = problems with &amp;amp;etls_jobName;

         filename sendMail email 
                to=         (&amp;amp;address) 
                subject=        "ETL Process problem: &amp;amp;etls_jobName." 
                attach=     "&amp;amp;path."; 

            options nosyntaxcheck;  

         data _null_; 
            dttm = put(datetime(),nldatm.);

                infile "&amp;amp;path.";
                input;

                file sendMail; 
                 if _n_ = 1 then do;
                    put "Date time: " dttm;
                    put;
                    put "Full log in attach.";
                    put "There are some ERRORs and WARNINGs:";
                    put;
                    end;
                 if substr(_infile_,1,5) = "ERROR" then 
                    put _infile_;
                 if substr(_infile_,1,7) = "WARNING" then 
                    put _infile_;
         run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In effect I get e-mail with log in attach, but empty body. In attached log I can see:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;NOTE: 0 records were read from the infile &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've got some questions:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Why 0 records???&lt;/LI&gt;&lt;LI&gt;When I delete&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;input;&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;statement from Postcode and run job I get e-mail with "Date time / Full log in attach / There are some ERRORs and WARNINGs" in body. Why they are deleted where&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;input&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;works in code?&lt;/LI&gt;&lt;LI&gt;E-mail is not sending without&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;options nosyntaxcheck;&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in code. Why?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Thanks for the answers. Regards, Michał&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 11:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Integration-Studio-e-mail-with-log/m-p/793450#M254334</guid>
      <dc:creator>MichalRa</dc:creator>
      <dc:date>2022-01-31T11:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Data Integration Studio - e-mail with log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Integration-Studio-e-mail-with-log/m-p/793470#M254349</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The answer to your third question may resolve the first two as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is an error in your SAS session and SAS enters syntaxcheck mode, no later data will be processed, and this would prevent your data _null_ step from reading in the data via the INPUT statement.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I take a similar log emailing approach in my DI jobs.&amp;nbsp; Before your log scanning / emailing code at the end, you can add:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  options obs=max replace NoSyntaxCheck;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This basically recovers from syntaxcheck mode, and tells SAS to go back to executing any following data steps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Q.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 14:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Integration-Studio-e-mail-with-log/m-p/793470#M254349</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-01-31T14:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data Integration Studio - e-mail with log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Integration-Studio-e-mail-with-log/m-p/793518#M254352</link>
      <description>Hi Quentin,&lt;BR /&gt;&lt;BR /&gt;thank you! The code is working fine now.</description>
      <pubDate>Mon, 31 Jan 2022 14:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Integration-Studio-e-mail-with-log/m-p/793518#M254352</guid>
      <dc:creator>MichalRa</dc:creator>
      <dc:date>2022-01-31T14:50:04Z</dc:date>
    </item>
  </channel>
</rss>

