<?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: Why is Call Execute running twice? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777786#M247520</link>
    <description>&lt;P&gt;Your code sends one email, not 5 or 10.&lt;/P&gt;</description>
    <pubDate>Mon, 01 Nov 2021 21:48:44 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-11-01T21:48:44Z</dc:date>
    <item>
      <title>Why is Call Execute running twice?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777784#M247518</link>
      <description>&lt;P&gt;Please see the below sample code,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am calling macro through Call execute based on a dataset. I want to send 1 email per observation in the dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg: If there are 5 obs, I want email to be sent to the email ID present in one of the variables. But it is sending same email twice, so am getting a total of 10 emails, instead of 5.&lt;/P&gt;&lt;P&gt;======================================================&lt;/P&gt;&lt;P&gt;%macro alertMail(a1, a2, a3, a4, a5, a6);&lt;BR /&gt;filename alerts1 email to="&amp;amp;emaila." from="abc.abc@123.com"&lt;BR /&gt;subject= "DEMO";&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;file alerts1;&lt;BR /&gt;put "Hi,";&lt;BR /&gt;put " ";&lt;BR /&gt;put "&amp;amp;a1 Approval Rate for &amp;amp;a2. is &amp;amp;a3 , is ";&lt;BR /&gt;put " ";&lt;BR /&gt;put " &amp;amp;a4 of &amp;amp;a5 from Application Channel &amp;amp;a6 ";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Temp1;&lt;/P&gt;&lt;P&gt;set demo nobs=obs;&lt;BR /&gt;call execute('%alertMail('||a1||','||a2||','||a3||',' ||a4|| ',' ||a5|| ','||a6||')');&lt;BR /&gt;stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;===================================================&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 21:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777784#M247518</guid>
      <dc:creator>pradeep_kadasi</dc:creator>
      <dc:date>2021-11-01T21:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Call Execute running twice?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777786#M247520</link>
      <description>&lt;P&gt;Your code sends one email, not 5 or 10.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Nov 2021 21:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777786#M247520</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-01T21:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Call Execute running twice?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777787#M247521</link>
      <description>&lt;P&gt;What does your SAS log report? In any case your DATA step should look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Temp1;
set demo;
call execute('%alertMail('||a1||','||a2||','||a3||',' ||a4|| ',' ||a5|| ','||a6||')');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Nov 2021 21:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777787#M247521</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-11-01T21:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Call Execute running twice?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777788#M247522</link>
      <description>Why do you have this option in there?&lt;BR /&gt;nobs=obs&lt;BR /&gt;&lt;BR /&gt;I think if you remove that it should send for once for each record in the demo set, which is what you're after.</description>
      <pubDate>Mon, 01 Nov 2021 21:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777788#M247522</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-11-01T21:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Call Execute running twice?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777806#M247536</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your filename statement sends email to &amp;amp;emaila, but that macro variable is never created in the macro.&amp;nbsp; I would try making a simple example (without the emailing), just so that you can focus on getting CALL EXECUTE working.&amp;nbsp; Once that is working like you want, you can add the emailing into the macro.&amp;nbsp; Below is a simplified example of your code, with the emailing removed.&amp;nbsp; I usually use %NRSTR() in call execute.&amp;nbsp; It simplifies macro timing (may or may not be an issue here, depending on what your real code is doing) and also makes the log much easier to read.&amp;nbsp; You can see in the log every macro invocation generated by CALL EXECUTE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro alertMail(a1, a2);
  data _null_;
    put "&amp;amp;a1 &amp;amp;a2";
  run;
%mend;

data demo ;
  input a1 : $5. a2 : $3.;
  cards ;
hi    mom
hello dad
;
run ;

data Temp1;
 set demo ;
 call execute('%nrstr(%%)alertMail('||a1||','||a2||')');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log is:&lt;/P&gt;
&lt;PRE&gt;NOTE: There were 2 observations read from the data set WORK.DEMO.
NOTE: The data set WORK.TEMP1 has 2 observations and 2 variables.

NOTE: CALL EXECUTE generated line.
1   + %alertMail(hi   ,mom)

hi mom

2   + %alertMail(hello,dad)

hello dad
&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Nov 2021 00:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777806#M247536</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-11-02T00:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Call Execute running twice?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777850#M247551</link>
      <description>&lt;P&gt;The NOBS= doesn't have an effect:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro testmac(name);
data _null_;
put "Name=&amp;amp;name.";
run;
%mend;

data _null_;
set sashelp.class nobs=obs;
call execute('%testmac('||name||')');
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log from SAS On Demand:&lt;/P&gt;
&lt;PRE&gt; 69         %macro testmac(name);
 70         data _null_;
 71         put "Name=&amp;amp;name.";
 72         run;
 73         %mend;
 74         
 75         data _null_;
 76         set sashelp.class nobs=obs;
 77         call execute('%testmac('||name||')');
 78         stop;
 79         run;
 
 NOTE: There were 1 observations read from the data set SASHELP.CLASS.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              619.68k
       OS Memory           23712.00k
       Timestamp           02.11.2021 09:19:21 vorm.
       Step Count                        24  Switch Count  0
       Page Faults                       0
       Page Reclaims                     94
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 
 NOTE: CALL EXECUTE generated line.
 1         + data _null_; put "Name=Alfred"; run;
 
 Name=Alfred
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              460.84k
       OS Memory           23712.00k
       Timestamp           02.11.2021 09:19:21 vorm.
       Step Count                        25  Switch Count  0
       Page Faults                       0
       Page Reclaims                     42
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 
 80         
&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Nov 2021 09:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-is-Call-Execute-running-twice/m-p/777850#M247551</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-02T09:51:50Z</dc:date>
    </item>
  </channel>
</rss>

