<?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 SAS Programing Sending Email Using macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765259#M242383</link>
    <description>&lt;P&gt;I have dataset below :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Son_Of_Krypton_0-1630484856716.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63200iFD8D83A840B8A8E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Son_Of_Krypton_0-1630484856716.png" alt="Son_Of_Krypton_0-1630484856716.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Below is macro code :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro zero_check;
data testing;
set Test3;
if TOTAL_PAYMENTS_TO_DATE_LATEST in (0,.) and TOTAL_PAYMENTS_TO_DATE_PREVIOUS notin (0,.)
then call symputx("val",1);
else call symputx("val",2);
/*run;*/



run;    
%put value=&amp;amp;val;


%if &amp;amp;val=1 %then 
%do;
filename SENDMAIL EMAIL to=("test@email.COM") subject="Found zero on TOTAL PAYMENTS TO DATE of Payments file but had a value previously"; 
data _null_;
	file SENDMAIL;
	put 'This email serves as notification that the value of column TOTAL PAYMENTS TO DATE of Payments file contains zero or blank';
	put /;
	put "File Name: &amp;amp;filename.";
	put /;
	put 'This message was sent from a notification-only email address that does not accept incoming email. Please do not reply to this message.' ;
run;
%end;

%else %do;

%end;
%mend;
%zero_check;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;based on above condition the value should be resolved to 2 instead it resolving to 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1009      %put value=&amp;amp;val;
value=1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;can somebody help me with this.??&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Sep 2021 08:32:49 GMT</pubDate>
    <dc:creator>Son_Of_Krypton</dc:creator>
    <dc:date>2021-09-01T08:32:49Z</dc:date>
    <item>
      <title>SAS Programing Sending Email Using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765259#M242383</link>
      <description>&lt;P&gt;I have dataset below :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Son_Of_Krypton_0-1630484856716.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63200iFD8D83A840B8A8E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Son_Of_Krypton_0-1630484856716.png" alt="Son_Of_Krypton_0-1630484856716.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Below is macro code :&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro zero_check;
data testing;
set Test3;
if TOTAL_PAYMENTS_TO_DATE_LATEST in (0,.) and TOTAL_PAYMENTS_TO_DATE_PREVIOUS notin (0,.)
then call symputx("val",1);
else call symputx("val",2);
/*run;*/



run;    
%put value=&amp;amp;val;


%if &amp;amp;val=1 %then 
%do;
filename SENDMAIL EMAIL to=("test@email.COM") subject="Found zero on TOTAL PAYMENTS TO DATE of Payments file but had a value previously"; 
data _null_;
	file SENDMAIL;
	put 'This email serves as notification that the value of column TOTAL PAYMENTS TO DATE of Payments file contains zero or blank';
	put /;
	put "File Name: &amp;amp;filename.";
	put /;
	put 'This message was sent from a notification-only email address that does not accept incoming email. Please do not reply to this message.' ;
run;
%end;

%else %do;

%end;
%mend;
%zero_check;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;based on above condition the value should be resolved to 2 instead it resolving to 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1009      %put value=&amp;amp;val;
value=1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;can somebody help me with this.??&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 08:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765259#M242383</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2021-09-01T08:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programing Sending Email Using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765260#M242384</link>
      <description>anybody can me guide me here how i can change the conditions</description>
      <pubDate>Wed, 01 Sep 2021 08:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765260#M242384</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2021-09-01T08:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programing Sending Email Using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765304#M242395</link>
      <description>&lt;P&gt;1) Could you share some example data for the Test3 dataset?&lt;/P&gt;
&lt;P&gt;2) If the Test3 has more than 1 observation then the `if` condition is tested and executed for each observation. So if the last observation resolves condition to false, than value will be 2, even if all previous were resolved to true.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 11:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765304#M242395</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-09-01T11:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programing Sending Email Using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765319#M242408</link>
      <description>&lt;P&gt;What do you get in the log if you run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testing;
  set Test3;
  put (TOTAL_PAYMENTS_TO_DATE_LATEST TOTAL_PAYMENTS_TO_DATE_PREVIOUS)(=);
  if TOTAL_PAYMENTS_TO_DATE_LATEST in (0,.) and TOTAL_PAYMENTS_TO_DATE_PREVIOUS notin (0,.) then call symputx("val",1);
  else call symputx("val",2);
run;    
%put value=&amp;amp;val;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Sep 2021 12:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765319#M242408</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-09-01T12:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programing Sending Email Using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765569#M242501</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: 0 observations were read from "WORK.Test3"
NOTE: Data set "WORK.testing" has 0 observation(s) and 3 variable(s)
NOTE: The data step took :
      real time       : 0.001
      user cpu time   : 0.000
      system cpu time : 0.001
      Timestamp       :   02SEP21:10:09:58
      Maximum resident set         : 144152k
      Page Faults                  : 0
      Page Reclaims                : 11
      Page Swaps                   : 0
      Voluntary Context Switches   : 0
      Involuntary Context Switches : 0
      Block Input Operations       : 0
      Block Output Operations      : 8


919       ;
920       %put value=&amp;amp;val.;
value=1
921       quit; run;
922       ODS _ALL_ CLOSE;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I still get value resolved to 1 it should resolve to 2 as dataset is empty&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 08:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765569#M242501</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2021-09-02T08:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programing Sending Email Using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765572#M242503</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TOTAL_PAYMENTS_TO_DATE_LATEST&amp;nbsp;&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;BR /&gt;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TOTAL_PAYMENTS_TO_DATE_PREVIOUS&lt;BR /&gt;3057.12&lt;BR /&gt;647&lt;BR /&gt;1073.12&lt;BR /&gt;300&lt;BR /&gt;968.01&lt;BR /&gt;638&lt;BR /&gt;745.16&lt;BR /&gt;2986.6&lt;BR /&gt;1095.89&lt;BR /&gt;600&lt;BR /&gt;1095.92&lt;BR /&gt;1540.23&lt;BR /&gt;345&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 08:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765572#M242503</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2021-09-02T08:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programing Sending Email Using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765587#M242513</link>
      <description>&lt;PRE&gt;NOTE: 0 observations were read from "WORK.Test3"&lt;/PRE&gt;
&lt;P&gt;Since no observation was read, the CALL SYMPUTX was never executed, and the macro variable kept its previous value.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 09:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765587#M242513</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-02T09:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programing Sending Email Using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765624#M242527</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/190967"&gt;@Son_Of_Krypton&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: 0 observations were read from "WORK.Test3"
NOTE: Data set "WORK.testing" has 0 observation(s) and 3 variable(s)

920       %put value=&amp;amp;val.;
value=1
921       quit; run;
922       ODS _ALL_ CLOSE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I still get value resolved to 1 it should resolve to 2 as dataset is empty&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As Kurt wrote, your CALL SYMPUTX statement is never executing.&amp;nbsp; If there are 0 obs in work.test3, when the below code runs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data testing;
  put "You will see me in the log because I execute before the SET statement";
  set Test3;
  put "You will not see me in the log because I never execute";
  put (TOTAL_PAYMENTS_TO_DATE_LATEST TOTAL_PAYMENTS_TO_DATE_PREVIOUS)(=);
  if TOTAL_PAYMENTS_TO_DATE_LATEST in (0,.) and TOTAL_PAYMENTS_TO_DATE_PREVIOUS notin (0,.) then call symputx("val",1);
  else call symputx("val",2);
run;   &lt;/PRE&gt;
&lt;P&gt;the step stops executing immediately when the SET statement executes and hits the (logical) end-of-file mark in the dataset.&amp;nbsp; So nothing after the SET statement will execute.&amp;nbsp; If you delete the macro var VAL before this step, you will see that after the step, the macro var VAL will not exist.&amp;nbsp; This is one of the challenges of working with global macro vars: they hang around in your session, and can cause confusion (for the programmer, not SAS &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 13:22:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Programing-Sending-Email-Using-macro/m-p/765624#M242527</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-09-02T13:22:08Z</dc:date>
    </item>
  </channel>
</rss>

