<?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 Re: Issue on email sending in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-on-email-sending/m-p/830444#M328143</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your quick response! It is possible, but looks like the code keep running after encountering the first error. Because, in my test code, I have one more data step to create a new table after the error process. The new table can be created successfully.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, may I know how to cancel the option of "&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lesysoptsref/n1w4v7ouc6vfhmn1cnsq5aunqk2j.htm#p1001quixnuxl8n1nu5hp9up8je2" target="_blank" rel="noopener"&gt;ERRORABEND&lt;/A&gt;"? I tried "Options = &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lesysoptsref/n1w4v7ouc6vfhmn1cnsq5aunqk2j.htm#p1001quixnuxl8n1nu5hp9up8je2" target="_blank" rel="noopener"&gt;NOERRORABEND&lt;/A&gt;;" at the first beginning of the code, but it still does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Wayne&lt;/P&gt;</description>
    <pubDate>Thu, 25 Aug 2022 21:14:26 GMT</pubDate>
    <dc:creator>qd96xuweifeng1</dc:creator>
    <dc:date>2022-08-25T21:14:26Z</dc:date>
    <item>
      <title>Issue on email sending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-on-email-sending/m-p/830435#M328135</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Recently, I encounter one problem on email sending. In my code, if there is no error (&amp;amp;syscc. = 0) the email will be sent with error free message. If&amp;nbsp;&amp;amp;syscc. &amp;lt;= 4, the email will be sent with warning message. Otherwise, the email will be sent with error alert message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code works well on Unix via SAS EG (&lt;FONT color="#FF0000"&gt;also run the code on Unix&lt;/FONT&gt;), and I can receive all these three type of messages under different situation. The log of "&lt;CODE class=""&gt;%f_notice;&lt;/CODE&gt;" for error alert message by SAS EG is below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;379        %f_notice;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
    
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
4                                                          The SAS System                            15:07 Thursday, August 25, 2022

NOTE: The file OUTBOX is:
      E-Mail Access Device

Message sent
      To:          "test@test.com"
      Cc:          
      Bcc:         
      Subject:     Test_Code run status for 202207
      Attachments: ( 
"/sasdata/Test_Code.log" CONTENT_TYPE = 
"application/txt" ) 
NOTE: 2 records were written to the file OUTBOX.
      The minimum record length was 66.
      The maximum record length was 141.
NOTE: There were 2 observations read from the data set WORK.BODY_FAIL.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.00 seconds
      
NOTE: Fileref OUTBOX has been deassigned.
380        &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I run it on Unix via "&lt;STRONG&gt;Tectia - SSH Terminal&lt;/STRONG&gt;", both "Error free" and "Warning" messages can be sent successfully, &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;but the message with "Error alert" cannot be sent.&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;The log of "&lt;CODE class=""&gt;%f_notice;&lt;/CODE&gt;" for error alert message by Unix via "&lt;STRONG&gt;Tectia - SSH Terminal&lt;/STRONG&gt;" is below:&lt;/P&gt;&lt;PRE&gt;354        %f_notice;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
NOTE: Fileref OUTBOX has been deassigned.
355        &lt;/PRE&gt;&lt;P&gt;The code is included as below. Could anyone please advise on this? Is there any difference on initial options between SAS EG and Unix environment caused this observation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion will be appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Wayne&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data body_Success;
length body $500.;
body = "The code of &amp;amp;report_code. is executed successfully without any issue for &amp;amp;YM_ID..
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;
Please find the details in the attached log."; output;

body = "&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;i&amp;gt;This is an automated e-mail. Please do not respond."; output;
run;

data body_Fail;
length body $500.;
body = "The code of &amp;amp;report_code. is failed on &amp;amp;YM_ID. execution.
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;
Please find the details in the attached log."; output;

body = "&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;i&amp;gt;This is an automated e-mail. Please do not respond."; output;
run;

data body_Warn;
length body $500.;
body = "The code of &amp;amp;report_code. is successfully executed for &amp;amp;YM_ID., but some warning messages are detected.
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;
Please find the details in the attached log."; output;

body = "&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;i&amp;gt;This is an automated e-mail. Please do not respond."; output;
run;


/* Email with XLSX attachments */
%macro EMAIL_XLSX (subject=, body=, to=, from=%str(Automated Process &amp;lt;do.not.reply@test.com&amp;gt;), attach1=, attach2=, attach3=, attach4=, attach5=);
data _null_;
call symput("to", tranwrd(trim(left(%trim("&amp;amp;to."))), " ", ",")); /* space delimited - replace all spaces with comma */
run;
data _null_;
length out $1024;
To = %trim("&amp;amp;to.");
do while (index(To,",")&amp;gt;0);
out = trim(out) || ' "' || trim(substr(To, 1, index(To,",")-1)) || '"';
To = strip(substr(To, index(To,",")+1, length(To)-index(To,",")));
end;
out = trim(out) || ' "' || trim(To) || '"';
out = trim(out);
call symput("To", out);
run;
filename outbox email "do.not.reply@test.com";

data _null_;
file outbox
to=(&amp;amp;to.)
from=("&amp;amp;from.")
sender=("&amp;amp;from.")
subject="&amp;amp;subject."
attach=("&amp;amp;attach1." content_type="application/txt")
type='text/html'
;
set &amp;amp;body.;
put Body;
run;
filename outbox clear;
%mend;

%macro f_notice;
%if &amp;amp;syscc. = 0 %then %do;

%EMAIL_XLSX(
subject=%str(&amp;amp;report_code. monthly run status for &amp;amp;YM_ID.),
body=body_Success,
to= &amp;amp;daily_exrtact_recipients.,
attach1=%str(&amp;amp;report_code_folder.&amp;amp;report_code..log)
);
%end;
%else %if &amp;amp;syscc. &amp;lt;= 4 %then %do;

%EMAIL_XLSX(
subject=%str(&amp;amp;report_code. monthly run status for &amp;amp;YM_ID.),
body=body_Warn,
to= &amp;amp;daily_exrtact_recipients.,
attach1=%str(&amp;amp;report_code_folder.&amp;amp;report_code..log)
);
%end;
%else %do;

%EMAIL_XLSX(
subject=%str(&amp;amp;report_code. monthly run status for &amp;amp;YM_ID.),
body=body_Fail,
to= &amp;amp;daily_exrtact_recipients.,
attach1=%str(&amp;amp;report_code_folder.&amp;amp;report_code..log)
);
%end;

%Mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 20:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-on-email-sending/m-p/830435#M328135</guid>
      <dc:creator>qd96xuweifeng1</dc:creator>
      <dc:date>2022-08-25T20:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issue on email sending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-on-email-sending/m-p/830443#M328142</link>
      <description>&lt;P&gt;Is it possible that in that other environment &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lesysoptsref/n074sx2hkq8dzpn1ptoydcmzfspt.htm" target="_self"&gt;OPTIONS ERRORABEND&lt;/A&gt; is set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H1 id="n1w4v7ouc6vfhmn1cnsq5aunqk2j" class="xisDoc-title"&gt;ERRORABEND System Option&lt;/H1&gt;
&lt;P class="xisDoc-shortDescription"&gt;Specifies whether SAS responds to errors by terminating.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 25 Aug 2022 20:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-on-email-sending/m-p/830443#M328142</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2022-08-25T20:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Issue on email sending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-on-email-sending/m-p/830444#M328143</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your quick response! It is possible, but looks like the code keep running after encountering the first error. Because, in my test code, I have one more data step to create a new table after the error process. The new table can be created successfully.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, may I know how to cancel the option of "&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lesysoptsref/n1w4v7ouc6vfhmn1cnsq5aunqk2j.htm#p1001quixnuxl8n1nu5hp9up8je2" target="_blank" rel="noopener"&gt;ERRORABEND&lt;/A&gt;"? I tried "Options = &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lesysoptsref/n1w4v7ouc6vfhmn1cnsq5aunqk2j.htm#p1001quixnuxl8n1nu5hp9up8je2" target="_blank" rel="noopener"&gt;NOERRORABEND&lt;/A&gt;;" at the first beginning of the code, but it still does not work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Wayne&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 21:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-on-email-sending/m-p/830444#M328143</guid>
      <dc:creator>qd96xuweifeng1</dc:creator>
      <dc:date>2022-08-25T21:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Issue on email sending</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-on-email-sending/m-p/830449#M328147</link>
      <description>&lt;P&gt;I just checked by&amp;nbsp;%put %sysfunc(getoption(errorabend));, and the value is 'NOERRORABEND'. Therefore, this should not be the root cause. I plan to compare all of options tomorrow to see if there is any difference between my EG and Unix environment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 22:39:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-on-email-sending/m-p/830449#M328147</guid>
      <dc:creator>qd96xuweifeng1</dc:creator>
      <dc:date>2022-08-25T22:39:55Z</dc:date>
    </item>
  </channel>
</rss>

