<?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: Sending Email in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869182#M343350</link>
    <description>SAS code to send the email, above is the&lt;BR /&gt;code I use to send the email. thank you.</description>
    <pubDate>Tue, 11 Apr 2023 19:18:42 GMT</pubDate>
    <dc:creator>Eugenio211</dc:creator>
    <dc:date>2023-04-11T19:18:42Z</dc:date>
    <item>
      <title>Sending Email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869166#M343339</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope all is well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anybody have an email code where in if there is data an email will send with attachment and if there is no data just an email saying 'no data to report'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 18:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869166#M343339</guid>
      <dc:creator>Eugenio211</dc:creator>
      <dc:date>2023-04-11T18:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869175#M343347</link>
      <description>&lt;P&gt;Please show your code which sends the mail when data is present.&lt;/P&gt;
&lt;P&gt;Also describe what you mean by "no data". Dataset does not exist, or dataset has zero observations?&lt;/P&gt;
&lt;P&gt;You can retrieve such information like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let data = 0;

proc sql noprint;
select nobs into :data from dictionary.tables
where libnamem= "YOURLIB" and memname = "YOURDATASET";
/* library and dataset name must be uppercase */
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then use &amp;amp;data in macro statements to run your code conditionally.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 18:56:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869175#M343347</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-11T18:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869180#M343348</link>
      <description>hi below is the code I use to send email with attachement, I just want to add a step that if there is no data generated i'll send an email without attachment. thank you.&lt;BR /&gt;&lt;BR /&gt;filename mymail email 'myemail@email.com' from='myemail@email.com'&lt;BR /&gt;                subject='Daily Chargebacks Report'&lt;BR /&gt;                attach=("\\shared\Auto Reports\Chargebacks Report.xlsx");&lt;BR /&gt;&lt;BR /&gt;data _null_;&lt;BR /&gt;    file mymail&lt;BR /&gt;    to=("someone@emailcom&lt;BR /&gt;        )&lt;BR /&gt;    cc=("myeamil@email.com");&lt;BR /&gt;    put 'Hi,';&lt;BR /&gt;    put ' ';&lt;BR /&gt;    put 'Attached is the Chargeback report.';&lt;BR /&gt;    put ' ';&lt;BR /&gt;    put 'Cheers';&lt;BR /&gt;run;</description>
      <pubDate>Tue, 11 Apr 2023 19:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869180#M343348</guid>
      <dc:creator>Eugenio211</dc:creator>
      <dc:date>2023-04-11T19:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869181#M343349</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/302621"&gt;@Eugenio211&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please clarify:&lt;/P&gt;
&lt;P&gt;Did you want&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;SAS code to send the email&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&amp;nbsp;OS script (Windows: PowerShell/Bat | Linux/Unix: Shell Script)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Which one?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The syntax would vary depending on your choice of language.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 19:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869181#M343349</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-04-11T19:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869182#M343350</link>
      <description>SAS code to send the email, above is the&lt;BR /&gt;code I use to send the email. thank you.</description>
      <pubDate>Tue, 11 Apr 2023 19:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869182#M343350</guid>
      <dc:creator>Eugenio211</dc:creator>
      <dc:date>2023-04-11T19:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869183#M343351</link>
      <description>IF you are using SAS 9.4 M5+, then you can add this to test for your data set&lt;BR /&gt;&lt;BR /&gt;%if (%sysfunc(exists(lib.dataset) GT 0) %then&lt;BR /&gt;%do;&lt;BR /&gt;%end;&lt;BR /&gt;More details are listed in this blog&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2018/07/05/if-then-else-sas-programs/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2018/07/05/if-then-else-sas-programs/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps</description>
      <pubDate>Tue, 11 Apr 2023 19:19:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869183#M343351</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-04-11T19:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sending Email</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869186#M343352</link>
      <description>&lt;P&gt;Use my previous code, then do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;data.
%then %do;

filename mymail email 'myemail@email.com' from='myemail@email.com'
subject='Daily Chargebacks Report'
attach=("\\shared\Auto Reports\Chargebacks Report.xlsx");

data _null_;
file mymail
to=("someone@emailcom
)
cc=("myeamil@email.com");
put 'Hi,';
put ' ';
put 'Attached is the Chargeback report.';
put ' ';
put 'Cheers';
run;

%end;
%else %do;

filename mymail email 'myemail@email.com' from='myemail@email.com'
subject='Daily Chargebacks Report'
;

data _null_;
file mymail
to=("someone@emailcom
)
cc=("myeamil@email.com");
put 'Hi,';
put ' ';
put 'No data was created!';
put ' ';
put 'Cheers';
run;

%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Apr 2023 19:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-Email/m-p/869186#M343352</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-11T19:24:27Z</dc:date>
    </item>
  </channel>
</rss>

