<?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: Understanding Call Execute in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/244119#M45459</link>
    <description>&lt;P&gt;No. %include is not going to&amp;nbsp;&lt;SPAN&gt;be interpreted, while call execute() will . Did you see my example at last ? That is reason explain why the macro variable is not resolved in LOG , but %include will not &amp;nbsp;complain that .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the code generated by call execute() will firstly pass through compiler and try to resolve macro value, if can't resolve , it will print a WARNING message.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the code generated by %include&amp;nbsp; will not&amp;nbsp;pass through&lt;SPAN&gt; compiler, just execute the code directly like it is in code editor .and you will not see any&amp;nbsp;WARNING message.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2016 01:08:21 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-01-18T01:08:21Z</dc:date>
    <item>
      <title>Understanding Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243666#M45337</link>
      <description>&lt;P&gt;Is there a functional&amp;nbsp;difference between these two code blocks?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename execute temp;
data _null_;
file execute; put "data test;";
do i = 1 to 5;
    file execute; put "x=" i "; output;";
    end;
file execute; put "run;";
run;
%include execute / source2;

data _null_;
call execute("data test;");
do i = 1 to 5;
    call execute(cats("x=", i, "; output;"));
    end;
call execute("run;");
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;They seem perfectly equivalent to me. When would the two programming approaches differ?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 03:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243666#M45337</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-01-15T03:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243678#M45341</link>
      <description>&lt;P&gt;They're the same (at least they appear to be) for this particular example, but there can be differences in theory. &amp;nbsp;Any macro language statements (%let, macro invocations, etc.) execute at different times with these two approaches. &amp;nbsp;Macro language statements execute immediately when initiated by CALL EXECUTE, which is not necessarily the order you would expect. &amp;nbsp;Only the SAS language statements generated by CALL EXECUTE wait for the current DATA step to complete. &amp;nbsp;On the other hand, %INCLUDE executes the statements in the order you would expect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A simple example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;call execute ('%let color=Blue; data test; color=symget("color"); run; %let color=Red;');&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 04:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243678#M45341</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-15T04:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243683#M45346</link>
      <description>&lt;P&gt;The&amp;nbsp;implied difference is %include will execute the code directly ,will not interpret it .&lt;/P&gt;
&lt;P&gt;While the code generated by &amp;nbsp;call execute() will be interpreted by compiler and then execute it .&lt;/P&gt;
&lt;P&gt;Therefore %include is going to be faster .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the small code , they are almost the same. I like CALL EXECUTE() better, but Tom like %include better though.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 04:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243683#M45346</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-15T04:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243688#M45347</link>
      <description>&lt;P&gt;Thanks! I tried&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let color=yellow;
data _null_;
call execute ('%let color=Blue; data test1; color=symget("color"); run; %let color=Red;');
color=symget("color");
put "Call Execute Color =" color;
run;

filename execute temp;
%let color=yellow;
data _null_;
file execute; put '%let color=Blue; data test2; color=symget("color"); run; %let color=Red;';
color=symget("color");
putlog "Include Temp File Color =" color;
run;
%include execute / source2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think I understand a bit better the difference now. As you said, what's going on is not immediately obvious. Would it be fair advice to keep &lt;STRONG&gt;call execute&lt;/STRONG&gt; for the simpler tasks where the timing of macro execution is not an issue?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 04:53:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243688#M45347</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-01-15T04:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243691#M45348</link>
      <description>&lt;P&gt;One more different is the order of macro variable&amp;nbsp;resolved is different .&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note: start two new sas session to run these two code&lt;/STRONG&gt; . and You will see the difference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;/* First Code*/&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;filename execute temp;&lt;BR /&gt;data _null_;&lt;BR /&gt;file execute; &lt;BR /&gt;i=1;&lt;BR /&gt;put 'data _null_;call symputx("x",' i ');run; %put &amp;amp;x;';&lt;BR /&gt;run;&lt;BR /&gt;%include execute / source2;&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;P&gt;&lt;STRONG&gt;/*Second Code*/&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;i=1;&lt;BR /&gt;call execute(cats('data _null_;call symputx("x",' ,i, ');run; %put &amp;amp;x;'));&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 05:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243691#M45348</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-15T05:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243762#M45365</link>
      <description>&lt;P&gt;My two cents: Writing the whole file and the using %INCLUDE is easier to understand and debug.&amp;nbsp; It works exactly like the corresponding SAS program would, and the interaction between global statements, macro, DATA step compilation, and DATA step execution is easier to figure out. As an added bonus, you can look at the program and even modify it if necessary.&amp;nbsp; You can also run the program many times without regenerating it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The fact that certain statements are executed immediately whereas others are compiled and then executed at runtime makes this a hard problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In an interactive procedure (DATASETS, SQL, GLM, IML, ...) the problems with combining macro and CALL EXECUTE can be even more complex. It can require understanding the way that SAS compiles and executes statements, as shown in this &lt;A href="http://blogs.sas.com/content/iml/2013/06/19/macros-and-loops.html" target="_self"&gt;PROC IML example that updates a macro variable in a loop.&lt;/A&gt;&amp;nbsp; See also this &lt;A href="http://blogs.sas.com/content/iml/2015/01/14/global-statements-loops.html" target="_self"&gt;example of using CALL EXECUTE to set a global statement&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 13:15:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243762#M45365</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-01-15T13:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243890#M45406</link>
      <description>I think in both cases %include or call execute the code has to be interpreted and then executed. I see no difference. Am I missing something?</description>
      <pubDate>Fri, 15 Jan 2016 19:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/243890#M45406</guid>
      <dc:creator>CatCol</dc:creator>
      <dc:date>2016-01-15T19:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Understanding Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/244119#M45459</link>
      <description>&lt;P&gt;No. %include is not going to&amp;nbsp;&lt;SPAN&gt;be interpreted, while call execute() will . Did you see my example at last ? That is reason explain why the macro variable is not resolved in LOG , but %include will not &amp;nbsp;complain that .&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the code generated by call execute() will firstly pass through compiler and try to resolve macro value, if can't resolve , it will print a WARNING message.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;the code generated by %include&amp;nbsp; will not&amp;nbsp;pass through&lt;SPAN&gt; compiler, just execute the code directly like it is in code editor .and you will not see any&amp;nbsp;WARNING message.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 01:08:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Understanding-Call-Execute/m-p/244119#M45459</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-18T01:08:21Z</dc:date>
    </item>
  </channel>
</rss>

