<?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: Macro Processor: correct reasoning? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Processor-correct-reasoning/m-p/444158#M111149</link>
    <description>&lt;P&gt;Doesn't sound like you need any help.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Mar 2018 15:32:12 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-03-09T15:32:12Z</dc:date>
    <item>
      <title>Macro Processor: correct reasoning?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Processor-correct-reasoning/m-p/443483#M110953</link>
      <description>&lt;P&gt;I am using SAS 9.4. I have the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;48221  %let userAsof='28FEB2018'd;
48222
48223  /*2.a)*/ %let lAsOf = intnx(month,&amp;amp;userAsOf.,0,e);
48224  %put lAsOf = &amp;amp;lAsof;
lAsOf = intnx(month,'28FEB2018'd,0,e)
48225
48226  /*2.b)*/ %let lAsOf = %sysfunc(intnx(month,&amp;amp;userAsOf.,0,e));
48227  %put lAsOf = &amp;amp;lAsof;
lAsOf = 21243&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to reason as to why the two outputs are different by thinking about the steps that are taken chronologically behind the scenes. Please tell me if I am wrong or there is anything to be added on. &lt;STRONG&gt;Differences in the steps are highlighted in bold.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. SAS recognizes the % sign to prompt the macro processor. userAsof is stored in Global Symbol table as text&amp;nbsp;'28FEB2018'd.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.A)&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;SAS recognizes the % sign to prompt the macro processor.&amp;nbsp;&lt;/SPAN&gt;lAsOf is stored in the Global Symbol table.&lt;/LI&gt;&lt;LI&gt;However, while evaluating the RHS expression,&amp;nbsp;&lt;SPAN&gt;SAS recognizes the&amp;nbsp;&amp;amp; sign to prompt the macro processor again. It finds the userAsof variable in the global symbol table and replaces the expression. &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;&lt;STRONG&gt;The rest of the RHS is not evaluated and remains as text because intnx is a datastep function and when setting a macro variable we're concerned with the macro processor and not the data step compiler.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.B)&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;SAS recognizes the % sign to prompt the macro processor.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;lAsOf is stored in the Global Symbol table.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;on the RHS,&amp;nbsp;SAS recognizes the % sign to prompt the macro processor. sysfunc tells SAS to evaluate the intnx datastep function. So we go to the data step compiler to compile and execute the intnx datastep function.&lt;/STRONG&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;while evaluating this expression,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;SAS recognizes the&amp;nbsp;&amp;amp; sign to prompt the macro processor again. It finds the userAsof variable in the global symbol table and replaces the expression.&amp;nbsp;&lt;STRONG&gt;Then SAS finishes&amp;nbsp;compiling and executing&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;the RHS expression.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Any help is appreciated. Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 20:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Processor-correct-reasoning/m-p/443483#M110953</guid>
      <dc:creator>dashsas</dc:creator>
      <dc:date>2018-03-07T20:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Processor: correct reasoning?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Processor-correct-reasoning/m-p/444156#M111147</link>
      <description>&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;</description>
      <pubDate>Fri, 09 Mar 2018 15:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Processor-correct-reasoning/m-p/444156#M111147</guid>
      <dc:creator>dashsas</dc:creator>
      <dc:date>2018-03-09T15:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Processor: correct reasoning?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Processor-correct-reasoning/m-p/444158#M111149</link>
      <description>&lt;P&gt;Doesn't sound like you need any help.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 15:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Processor-correct-reasoning/m-p/444158#M111149</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-09T15:32:12Z</dc:date>
    </item>
  </channel>
</rss>

