<?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 macro is being called more than it supposed to call in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-is-being-called-more-than-it-supposed-to-call/m-p/529903#M144864</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the below is a macro calling another macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro one;&lt;/P&gt;&lt;P&gt;data callinsertcustcomms;&lt;BR /&gt;set two;&lt;BR /&gt;length id $3000;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;id = catx("|", ciskey, emailunsubscribeflag,datefirstjoined,tenure,tierid,commstypeid, commschannel,&lt;BR /&gt;PrevTierDataFlag,CustExpBal,MaxBankRewards,&lt;BR /&gt;CumRewardsValue,CalcItemsFlag,Misc1,Misc2,Misc3,Misc4,Misc5) ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;insertcustcomms = cats('%nrstr(%b('!!trim(id)!!'))');&lt;BR /&gt;put insertcustcomms;&lt;BR /&gt;call execute ( insertcustcomms ) ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;BR /&gt;%one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro b(monthlyNL);&lt;BR /&gt;%put great;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in the first macro the table&amp;nbsp;callinsertcustcomms has 47708 rows.Ideally the macro b should be called 47708 times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is called 47742 times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Request your help!&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jan 2019 22:42:43 GMT</pubDate>
    <dc:creator>Swathi12</dc:creator>
    <dc:date>2019-01-24T22:42:43Z</dc:date>
    <item>
      <title>sas macro is being called more than it supposed to call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-is-being-called-more-than-it-supposed-to-call/m-p/529903#M144864</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the below is a macro calling another macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro one;&lt;/P&gt;&lt;P&gt;data callinsertcustcomms;&lt;BR /&gt;set two;&lt;BR /&gt;length id $3000;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;id = catx("|", ciskey, emailunsubscribeflag,datefirstjoined,tenure,tierid,commstypeid, commschannel,&lt;BR /&gt;PrevTierDataFlag,CustExpBal,MaxBankRewards,&lt;BR /&gt;CumRewardsValue,CalcItemsFlag,Misc1,Misc2,Misc3,Misc4,Misc5) ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;insertcustcomms = cats('%nrstr(%b('!!trim(id)!!'))');&lt;BR /&gt;put insertcustcomms;&lt;BR /&gt;call execute ( insertcustcomms ) ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;BR /&gt;%one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro b(monthlyNL);&lt;BR /&gt;%put great;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in the first macro the table&amp;nbsp;callinsertcustcomms has 47708 rows.Ideally the macro b should be called 47708 times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is called 47742 times.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Request your help!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 22:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-is-being-called-more-than-it-supposed-to-call/m-p/529903#M144864</guid>
      <dc:creator>Swathi12</dc:creator>
      <dc:date>2019-01-24T22:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: sas macro is being called more than it supposed to call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-is-being-called-more-than-it-supposed-to-call/m-p/529914#M144868</link>
      <description>&lt;P&gt;I do not see how it could call the macro more times than the number of observations in the input dataset, unless the macro calls itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your macro %ONE does not appear to have any macro code in it. Why is it coded as a macro and not just a data step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find it much easier to use a PUT statement to write the code to a file and then %INCLUDE the file instead of using CALL EXECUTE.&lt;/P&gt;
&lt;P&gt;That way you can run the step that generates the code and check the code before running it to make sure you have the code generation correct.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data callinsertcustcomms;
  set two;
  length id $3000;
  id = catx("|", of 
    ciskey emailunsubscribeflag datefirstjoined tenure tierid
    commstypeid commschannel PrevTierDataFlag CustExpBal MaxBankRewards
    CumRewardsValue CalcItemsFlag Misc1-Misc5
    ) 
  ;
  file code ;
  put '%b(' id ')';
run;
%include code / source2;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A process that calls a macro 47 thousand times is probably not a good process.&lt;/P&gt;
&lt;P&gt;What is it that you are actually trying to do? Does it even require any macros?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 23:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-is-being-called-more-than-it-supposed-to-call/m-p/529914#M144868</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-24T23:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: sas macro is being called more than it supposed to call</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-macro-is-being-called-more-than-it-supposed-to-call/m-p/529925#M144874</link>
      <description>&lt;P&gt;Please describe how you know that the macro is called 47742 times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your demonstrated macro B basically does nothing I doubt that you counted "great" 47742 times in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might suspect that your macro B has some %if code in there and the stuff in the parameter is sometimes hitting a boundary condition or two that are using LE and GE with some equal values where not expected causing a few records to do *something* more than once for some values of ID.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2019 23:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-macro-is-being-called-more-than-it-supposed-to-call/m-p/529925#M144874</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-24T23:50:43Z</dc:date>
    </item>
  </channel>
</rss>

