<?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: How to email and update in a single step using SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-email-and-update-in-a-single-step-using-SAS/m-p/321199#M70870</link>
    <description>&lt;P&gt;I cannot test it, but mainly I believe it is posiible.&lt;/P&gt;
&lt;P&gt;I sugget to try it on a sample in work library;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FILENAME OUTBOX ...;&lt;/P&gt;
&lt;P&gt;data &amp;lt;dsname&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; modify &amp;lt;dsname&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if flag = 0 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file outbox ...;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; to = ...;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cc = ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; subject = ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; put ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if _iorc_ = 0 then replace;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Dec 2016 17:15:55 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2016-12-26T17:15:55Z</dc:date>
    <item>
      <title>How to email and update in a single step using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-email-and-update-in-a-single-step-using-SAS/m-p/320029#M70400</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code that sends email and updates a column (process_flag) to E after the email has been sent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;Connect to Greenplm as dbcon (user=xxxxx pw=xxxxx server=xxxxx port=xxxxx database=xxxxxx);&lt;/P&gt;&lt;P&gt;SELECT * INTO :email_flg&lt;BR /&gt;FROM connection to dbcon (&lt;BR /&gt;SELECT count(1)::smallint&lt;BR /&gt;FROM f2_t1&lt;BR /&gt;WHERE rflag = 1 AND (process_flag &amp;lt;&amp;gt; 'E')&lt;BR /&gt;);&lt;BR /&gt;disconnect from dbcon;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%let email_body = Hello world;&lt;BR /&gt;%let to = aa@ss.com;&lt;BR /&gt;%let cc = ab@ss.com&lt;BR /&gt;%let subject_text = Test;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%if &amp;amp;email_flg &amp;gt; 0 %then %do;&lt;/P&gt;&lt;P&gt;filename outbox email &amp;amp;to;&lt;BR /&gt;data _null_;&lt;BR /&gt;file outbox&lt;BR /&gt;to=(&amp;amp;to)&lt;BR /&gt;cc=(&amp;amp;cc)&lt;BR /&gt;subject=&amp;amp;subject_text&lt;BR /&gt;;&lt;BR /&gt;put &amp;amp;email_body;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;Connect to xxxx&amp;nbsp;as dbcon (user=xxx pw=xxx server=xxxx port=xxxx database=xxxxx);&lt;BR /&gt;execute ( update f2_t1 set process_flag = 'E' where run_flag = 1) by dbcon ;&lt;BR /&gt;disconnect from dbcon;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am updating the process_flag to E once the email for the process has been sent. I create the email_flg to ensure that email doesn't get sent again.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But if the process fails after the email step and before the update statement, the email gets sent twice (or multiple times if the failure keeps occuring after the email step). Is there a way where it is possible to email and do the update in single transaction so that sending email fails if the update fails and vice versa? Or is there any other way to accomplish this scenario in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2016 15:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-email-and-update-in-a-single-step-using-SAS/m-p/320029#M70400</guid>
      <dc:creator>SASdn</dc:creator>
      <dc:date>2016-12-20T15:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to email and update in a single step using SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-email-and-update-in-a-single-step-using-SAS/m-p/321199#M70870</link>
      <description>&lt;P&gt;I cannot test it, but mainly I believe it is posiible.&lt;/P&gt;
&lt;P&gt;I sugget to try it on a sample in work library;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FILENAME OUTBOX ...;&lt;/P&gt;
&lt;P&gt;data &amp;lt;dsname&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; modify &amp;lt;dsname&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if flag = 0 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file outbox ...;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; to = ...;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cc = ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; subject = ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; put ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if _iorc_ = 0 then replace;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Dec 2016 17:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-email-and-update-in-a-single-step-using-SAS/m-p/321199#M70870</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-26T17:15:55Z</dc:date>
    </item>
  </channel>
</rss>

