<?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: Send email from SAS based on condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519930#M140927</link>
    <description>&lt;P&gt;This:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;GTU&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;AGSR&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;wrk1&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;SAS_workDDAB00005A48_dlusas003g&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;linux&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;dv&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;be&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;SAS_work2F2C00005A48_dlu0usas003g&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;linux&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;dv&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;be&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;email&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;sas7bdat&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does not look right, you have a path, then some what I guess to be some sort of url or something with the linux.dv.be.&lt;/P&gt;
&lt;P&gt;Afraid you need to find what the real path is on your system, I do not know what your setup is.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Dec 2018 12:35:13 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-12-10T12:35:13Z</dc:date>
    <item>
      <title>Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519835#M140884</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to send an email via SAS. If the condition (see the if clause below) from below program is true I want the value of the put statement in the email otherwise 'crefius' dataset to attached in the email.&amp;nbsp;. Could someone of you assist me tweaking the code below to send an email only if the condition is true? I'm OK to convert the SAS dataset to flat files to attach in the email if there is no way to attach a SaS dataset in the email.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mymail email ("babloo.kiya@xxx.com")
	subject='CREFIUS Table status' attach='crefius';

data email (rename=card=Num_of_observations rename=lastused=Processed_Date drop=curr_month);
file mymail;
set Crefius;
curr_month=intnx('month',today(),0);
format curr_month date9.;
if month(lastused) ne month(curr_month) then
put 'Inspect the Crefius Tables';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 06:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519835#M140884</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-12-10T06:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519854#M140894</link>
      <description>&lt;P&gt;First of all, it is rarely a good idea to attach data to an email:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;emails are NOT safe, unless you have end-to-end encryption enforced (not enabled, ENFORCED!)&lt;/LI&gt;
&lt;LI&gt;emails only work up to a given size (dependent on the mailserver settings of the recipient, and are rejected if that size is exceeded)&lt;/LI&gt;
&lt;LI&gt;still, large emails clutter up the mailbox, and you won't make friends of the admin(s) of the recipient(s) if you repeatedly cause trouble&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Put the data in a safe and accessible location (reachable through https/sftp/ftps/ssh) for download, and just send a notification message:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set Crefius (obs=1);
curr_month=intnx('month',today(),0);
format curr_month date9.;
if month(lastused) ne month(curr_month)
then call symput('message','Inspect the Crefius Tables');
else call symput('message','Crefius Tables ready for download');
run;

filename mymail email ("babloo.kiya@xxx.com")
	subject='CREFIUS Table status';

data _null_;
file mymail;
put "&amp;amp;message.";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Dec 2018 08:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519854#M140894</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-10T08:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519859#M140895</link>
      <description>&lt;P&gt;If you use the search functionality on here before posting, you will see that that exact question has been asked several times recently, as recent as last week:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/forums/searchpage/tab/message?advanced=false&amp;amp;allow_punctuation=false&amp;amp;q=send+email+conditionally" target="_blank"&gt;https://communities.sas.com/t5/forums/searchpage/tab/message?advanced=false&amp;amp;allow_punctuation=false&amp;amp;q=send+email+conditionally&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 08:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519859#M140895</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-10T08:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519868#M140900</link>
      <description>&lt;P&gt;I'm receiving the error as follows. May I know what might be the likely cause for this error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;50         filename mymail email ("babloo.kiya@xxx.com")
51         	subject='CREFIUS Table status' attach=email.sas7bdat;

52         
53         data email (rename=card=Num_of_observations rename=lastused=Processed_Date drop=curr_month);
54         /*file mymail;*/
55         set Crefius;
56         curr_month=intnx('month',today(),0);
57         format curr_month date9.;
58         if month(lastused) ne month(curr_month) then
59         call symput('message','Inspect the Crefius Tables');
60         else call symput('message','Crefius Tables ready for download');
61         run;

NOTE: There were 15 observations read from the data set WORK.CREFIUS.
NOTE: The data set WORK.EMAIL has 15 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

62         
63         
64         data _null_;
65         file mymail;
66         set email;
67         put "&amp;amp;message.";
68         run;

NOTE: The file MYMAIL is:
      E-Mail Access Device

ERROR: Error opening attachment file EMAIL.SAS7BDAT.
ERROR: Physical file does not exist, /GTU/AGSR/bin1/SASConfigFolder/Lev2/SASDIT/EMAIL.SAS7BDAT.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Dec 2018 09:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519868#M140900</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-12-10T09:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519871#M140901</link>
      <description>&lt;P&gt;DO NOT SEND DATA VIA EMAIL!&lt;/P&gt;
&lt;P&gt;DO NOT SEND DATA VIA EMAIL!&lt;/P&gt;
&lt;P&gt;DO NOT SEND DATA VIA EMAIL!&lt;/P&gt;
&lt;P&gt;DO NOT SEND DATA VIA EMAIL!&lt;/P&gt;
&lt;P&gt;DO NOT SEND DATA VIA EMAIL!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you get the message now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, you need to supply an absolute path for attachments, otherwise SAS goes looking in the current working directory.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 09:13:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519871#M140901</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-10T09:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519890#M140904</link>
      <description>Could you please tell me how I can find the path for WORK data set?&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Dec 2018 10:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519890#M140904</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-12-10T10:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519893#M140905</link>
      <description>&lt;PRE&gt;attach="%sysfunc(pathname(work))/email.sas7bdat";&lt;/PRE&gt;
&lt;P&gt;Of course you wont need that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 10:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519893#M140905</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-10T10:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519914#M140917</link>
      <description>&lt;P&gt;I'm receiving this error after updating the filename statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;RROR: Error opening attachment file 
       /GTU/AGSR/wrk1/SAS_workDDAB00005A48_dlusas003g.linux.dv.be/SAS_work2F2C00005A48_dlu0usas003g.linux.dv.be/email.sas7bdat.
ERROR: Physical file does not exist, 
       /GTU/AGSR/wrk1/SAS_workDDAB00005A48_dlusas003g.linux.dv.be/SAS_work2F2C00005A48_dlu0usas003g.linux.dv.be/email.sas7bdat.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Filename statement is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mymail email ("babloo.kiya@xxx.com")
	subject='CREFIUS Table status' attach="%sysfunc(pathname(work))/email.sas7bdat";;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519914#M140917</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-12-10T12:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519927#M140924</link>
      <description>&lt;P&gt;When SAS tells you that a file is not there, it's not there, period. Make sure that you really create that dataset as work.email before you try to send it.&lt;/P&gt;
&lt;P&gt;Keep an eye on your infrastructure; if you're working on a grid, the task that created the dataset may have run on a different node than the one that sends the email.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519927#M140924</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-10T12:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519930#M140927</link>
      <description>&lt;P&gt;This:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;GTU&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;AGSR&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;wrk1&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;SAS_workDDAB00005A48_dlusas003g&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;linux&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;dv&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;be&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;SAS_work2F2C00005A48_dlu0usas003g&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;linux&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;dv&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;be&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;email&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;sas7bdat&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does not look right, you have a path, then some what I guess to be some sort of url or something with the linux.dv.be.&lt;/P&gt;
&lt;P&gt;Afraid you need to find what the real path is on your system, I do not know what your setup is.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519930#M140927</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-10T12:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519936#M140932</link>
      <description>&lt;P&gt;I guess that, depending on the system setup, SAS might use the fully qualified domain name of the server in the directory name.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 12:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519936#M140932</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-10T12:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519943#M140936</link>
      <description>&lt;P&gt;I suppose you could try checking that the data set exists with code like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  set "%sysfunc(pathname(work))/email.sas7bdat" ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or maybe better, look through the file system to make your email.sas7bdat exists in the directory, and has the correct extension etc.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 13:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/519943#M140936</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-12-10T13:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/520249#M141044</link>
      <description>&lt;P&gt;I tried the code as you mentioned and the log says,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;59         data _null_ ;
60           set "%sysfunc(pathname(work))/email.sas7bdat" ;
61         run ;

NOTE: There were 15 observations read from the data set 
      /GTU/AGSR/wrk1/SAS_workC2A2000014B9_dlu0usas003g.linux.dv.be/SAS_workB91E000014B9_dlu0usas003g.linux.dv.be/email.sas7bdat.
NOTE: DATA statement used (Total process time)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then I &amp;nbsp;modified the 'attach' option inn Filename statement as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
          filename mymail email ("babloo.kiya@xxx.com")
         subject='CREFIUS Table status' attach='/GTU/AGSR/wrk1/SAS_workC2A2000014B9_dlu0usas003g.linux.dv.be/SAS_workB91E000014B9_dlu0usas003g.linux.dv.be/email.sas7bdat';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;But still I end up with the same error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;50         data email (rename=card=Num_of_observations rename=lastused=Processed_Date drop=curr_month);
51         file mymail;
52         set Crefius;
53         curr_month=intnx('month',today(),0);
54         format curr_month date9.;
55         if month(lastused) ne month(curr_month) then
56         put 'Inspect the Crefius Tables';
57         run;

NOTE: The file MYMAIL is:
      E-Mail Access Device

ERROR: Error opening attachment file 
       /GTU/AGSR/wrk1/SAS_workC2A2000014B9_dlu0usas003g.linux.dv.be/SAS_workB91E000014B9_dlu0usas003g.linux.dv.be/email.sas7bdat.
ERROR: File is in use, 
       /GTU/AGSR/wrk1/SAS_workC2A2000014B9_dlu0usas003g.linux.dv.be/SAS_workB91E000014B9_dlu0usas003g.linux.dv.be/email.sas7bdat.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Could you please help me understand how to find the file system to know the right path for WORK dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 06:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/520249#M141044</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-12-11T06:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/520275#M141048</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried the code as you mentioned and the log says,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;59         data _null_ ;
60           set "%sysfunc(pathname(work))/email.sas7bdat" ;
61         run ;

NOTE: There were 15 observations read from the data set 
      /GTU/AGSR/wrk1/SAS_workC2A2000014B9_dlu0usas003g.linux.dv.be/SAS_workB91E000014B9_dlu0usas003g.linux.dv.be/email.sas7bdat.
NOTE: DATA statement used (Total process time)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then I &amp;nbsp;modified the 'attach' option inn Filename statement as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
          filename mymail email ("babloo.kiya@xxx.com")
         subject='CREFIUS Table status' attach='/GTU/AGSR/wrk1/SAS_workC2A2000014B9_dlu0usas003g.linux.dv.be/SAS_workB91E000014B9_dlu0usas003g.linux.dv.be/email.sas7bdat';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;But still I end up with the same error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;50         data email (rename=card=Num_of_observations rename=lastused=Processed_Date drop=curr_month);
51         file mymail;
52         set Crefius;
53         curr_month=intnx('month',today(),0);
54         format curr_month date9.;
55         if month(lastused) ne month(curr_month) then
56         put 'Inspect the Crefius Tables';
57         run;

NOTE: The file MYMAIL is:
      E-Mail Access Device

ERROR: Error opening attachment file 
       /GTU/AGSR/wrk1/SAS_workC2A2000014B9_dlu0usas003g.linux.dv.be/SAS_workB91E000014B9_dlu0usas003g.linux.dv.be/email.sas7bdat.
ERROR: File is in use, 
       /GTU/AGSR/wrk1/SAS_workC2A2000014B9_dlu0usas003g.linux.dv.be/SAS_workB91E000014B9_dlu0usas003g.linux.dv.be/email.sas7bdat.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Could you please help me understand how to find the file system to know the right path for WORK dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Pay attention to log details. Now it does not complain about a file not found, but a file in use. That's because you use the dataset both as attachment and as source dataset in the set statement.&lt;/P&gt;
&lt;P&gt;I already showed you how to make the decision in a previous step and save the message to a macro variable.&lt;/P&gt;
&lt;P&gt;There's also not much sense putting the message for every observation of crefius, so it's not needed in the data step that actually sends the mail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ceterum censeo: do not send datasets as attachments.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 07:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/520275#M141048</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-11T07:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Send email from SAS based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/520315#M141066</link>
      <description>&lt;P&gt;I just noticed that folder for WORK dataset changes everytime. So I tried to tweak the 'attach' option as follows, but I ended up with error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mymail email ("baloo.kiya@xxx.com")
         subject='CREFIUS Table status' attach='%sysfunc(pathname(work))/email.sas7bdat';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;60         data _null_ ;
61         file mymail;
62           put "&amp;amp;message.";
63         run ;

NOTE: The file MYMAIL is:
      E-Mail Access Device

ERROR: Error opening attachment file %sysfunc(pathname(work))/email.sas7bdat.
ERROR: Physical file does not exist, /GTU/AGSR/bin1/SASConfigFolder/Lev2/SASDIT/%sysfunc(pathname(work))/email.sas7bdat.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 11:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Send-email-from-SAS-based-on-condition/m-p/520315#M141066</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-12-11T11:13:23Z</dc:date>
    </item>
  </channel>
</rss>

