<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/399917#M96892</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let a=12&amp;nbsp; is text for macro, but not for SAS.&amp;nbsp; The expression&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where age &amp;lt; &amp;amp;a&lt;/P&gt;
&lt;P&gt;is translated by the macro processor to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where age &amp;lt; 12;&lt;/P&gt;
&lt;P&gt;which is specifying the numeric literal 12.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wanted text, you could have used&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where age &amp;lt;= "&amp;amp;a" ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course SAS would have objected to comparing numeric variable AGE to a character literal value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Sep 2017 20:28:31 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-09-29T20:28:31Z</dc:date>
    <item>
      <title>Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/399911#M96891</link>
      <description>&lt;P&gt;Dear Members,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I came across a silly query. I hope I get a better solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Consider this code. I define a macro var a whose value is 12(which is text for SAS).&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I compare this macro var through where statement then how sas&amp;nbsp;is transforming this 12(text) to numerical 12?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let a= 12;&lt;BR /&gt;proc print data=sashelp.class;&lt;BR /&gt;where age &amp;lt;= &amp;amp;a;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 20:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/399911#M96891</guid>
      <dc:creator>Arun_shSAS</dc:creator>
      <dc:date>2017-09-29T20:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/399917#M96892</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let a=12&amp;nbsp; is text for macro, but not for SAS.&amp;nbsp; The expression&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where age &amp;lt; &amp;amp;a&lt;/P&gt;
&lt;P&gt;is translated by the macro processor to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where age &amp;lt; 12;&lt;/P&gt;
&lt;P&gt;which is specifying the numeric literal 12.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you wanted text, you could have used&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where age &amp;lt;= "&amp;amp;a" ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course SAS would have objected to comparing numeric variable AGE to a character literal value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 20:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/399917#M96892</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-29T20:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/399918#M96893</link>
      <description>&lt;P&gt;Also, this is a classic example of&lt;STRONG&gt;&lt;EM&gt; timing, and tokenisation&lt;/EM&gt;&lt;/STRONG&gt;. At compile time the macro resolution occurs and the tokens or in other words text remains as in the input stack. At this moment, the compiler is requesting tokens from the input stack. When resolution completes i.e &amp;amp;a becomes 12, the statements&amp;nbsp; move to the complier and the 12 along with moves as a numeric token. Now, your compiled text executes. I hope this helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can see and appeciate the beauty of tokenisation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best way to remember this, when macro triggers and macro processor are in action, tokenisation pauses and everything in the input stack pretty much sleeps. Once, the macro resolution completes, tokenisation resumes and each token is sent to compiler for execution where operands and operators work as expected&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2017 20:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/399918#M96893</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-09-29T20:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/399999#M96925</link>
      <description>&lt;P&gt;I have no disagreements with the previous responders.&amp;nbsp; I just think this explanation would help you understand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Consider this slightly different program:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let a=12;&lt;/P&gt;
&lt;P&gt;proc print data=sashelp.class;&lt;BR /&gt;where age &amp;lt;= &amp;amp;a;&lt;/P&gt;
&lt;P&gt;title "Results for Age &amp;lt; &amp;amp;a";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro language makes no judgement about &amp;amp;a being numeric or character.&amp;nbsp; Instead, it replaces "&amp;amp;a" with "12" so that SAS language sees:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=sashelp.class;&lt;/P&gt;
&lt;P&gt;where age &amp;lt;= 12;&lt;/P&gt;
&lt;P&gt;title "Results for Age &amp;lt; 12";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS language interprets the program, after macro language has finished substituting for &amp;amp;a.&amp;nbsp; SAS language alone makes the judgment about whether it is encountering text or a number.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Sep 2017 13:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro/m-p/399999#M96925</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-30T13:29:13Z</dc:date>
    </item>
  </channel>
</rss>

