<?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: Call Execute in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375000#M89853</link>
    <description>&lt;P&gt;The data step in the macro can only be compiled and run after the data step with the call execute has finished. Macro code in a macro that is call executed, OTOH, will be resolved immediately when pushed into the SAS interpreter queue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use data from a second dataset dynamically, but in a way that can not be handled by a join, consider using a hash object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you only use an overall statistic from dataset have, I'd prepare that beforehand. No need to reread the whole dataset in every iteration.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2017 15:10:41 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-07-11T15:10:41Z</dc:date>
    <item>
      <title>Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/374932#M89823</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One can not invoke a macro using Call execute&amp;nbsp;in oder to handle a created global macro&amp;nbsp;var by call sypmut.&lt;/P&gt;&lt;P&gt;How is that ? Any minds is welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 12:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/374932#M89823</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-07-11T12:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/374934#M89824</link>
      <description>&lt;P&gt;I think the documentation explains how to do that&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=mcrolref&amp;amp;docsetTarget=n1q1527d51eivsn1ob5hnz0yd1hx.htm&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=mcrolref&amp;amp;docsetTarget=n1q1527d51eivsn1ob5hnz0yd1hx.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 13:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/374934#M89824</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-11T13:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/374937#M89825</link>
      <description>&lt;P&gt;Post your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymac(varname);
%put Variable as received by macro: &amp;amp;&amp;amp;&amp;amp;varname;
%mend;

data _null_;
call symputx('myvar','mytext','g');
call execute('%mymac(myvar)');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log from that:&lt;/P&gt;
&lt;PRE&gt;24         %macro mymac(varname);
25         %put Variable as received by macro: &amp;amp;&amp;amp;&amp;amp;varname;
26         %mend;
27         
28         data _null_;
29         call symputx('myvar','mytext','g');
30         call execute('%mymac(myvar)');
31         run;

Variable as received by macro: mytext
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 13:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/374937#M89825</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-11T13:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/374990#M89846</link>
      <description>&lt;P&gt;Look at this example: val_m2 values are not updated form call execute.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do i=1 to 10;
	have= i+1;
	output;
end;
run;

%macro mymacro(nc);
%Global used mg1 mg2;
%let mg1= 20; %let mg2= 40;
data need; set have nobs= nobs; J= _n_;
var0= J * &amp;amp;mg1 / &amp;amp;mg2;     				
var1= var0 + 0.5 * &amp;amp;mg1 / &amp;amp;mg2;
var2= var0 + var1;
nexp= var2 * &amp;amp;mg1 / &amp;amp;mg2;
need + (((nexp - have)**2) / nexp);           /*cumulative sum*/ 
if J= nobs then	call symput('used',need); 
run;
%mend;

data see;
do i= 1 to 3;
	if i= 1 then do;
		max= 40;  min= 15;  m1= 27.5; 
		val_m1= 2;  m2= 33.75;   
		call execute('%mymacro('||m2||')');
		val_m2= input(symget('used'), 30.);    /*updating*/              
	end;
	else do;
		min= m1;  m1= m2;  val_m1= val_m2;  m2= (m2 + max)/2;   /*updating*/		
		call execute('%mymacro('||m2||')');
		val_m2 = input(symget('used'), 30.);
	end;
output;
end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 14:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/374990#M89846</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-07-11T14:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375000#M89853</link>
      <description>&lt;P&gt;The data step in the macro can only be compiled and run after the data step with the call execute has finished. Macro code in a macro that is call executed, OTOH, will be resolved immediately when pushed into the SAS interpreter queue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use data from a second dataset dynamically, but in a way that can not be handled by a join, consider using a hash object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you only use an overall statistic from dataset have, I'd prepare that beforehand. No need to reread the whole dataset in every iteration.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 15:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375000#M89853</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-11T15:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375006#M89858</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;An overall statistics is not used. When the macro execute, it use the current&amp;nbsp;variable have value.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 15:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375006#M89858</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-07-11T15:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375009#M89859</link>
      <description>&lt;P&gt;Also, the macro executes with the last m2 value as argument.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 15:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375009#M89859</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-07-11T15:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375012#M89861</link>
      <description>&lt;P&gt;Since dataset 'have' never changes, and only the results of the final iteration of the data step are put into the macro variable, and the code in the macro is not dynamic at all, there is no need to call the macro at all. Just set &amp;amp;need once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you plan on doing something completely different, show THAT code.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 15:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375012#M89861</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-11T15:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375023#M89867</link>
      <description>&lt;P&gt;Where you use these two lines in the data step:&lt;/P&gt;
&lt;P&gt;call &lt;SPAN class="token keyword"&gt;execute&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'%mymacro('&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;||&lt;/SPAN&gt;m2&lt;SPAN class="token operator"&gt;||&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;')'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&amp;nbsp;&amp;nbsp;&amp;lt;= creates a call to the macro that executes AFTER the data step&lt;/SPAN&gt;&lt;BR /&gt; val_m2&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;symget&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'used'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;30&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;lt;= so the value of USED is not changed prior to this line. It will be the same value for every iteration&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you intentionally through away and decimal part of used?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 15:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375023#M89867</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-11T15:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Call Execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375242#M89929</link>
      <description>&lt;P&gt;No i don't thinnk so.&lt;/P&gt;&lt;P&gt;Your explanations are so clear, thanks for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 08:58:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Execute/m-p/375242#M89929</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-07-12T08:58:47Z</dc:date>
    </item>
  </channel>
</rss>

