<?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 compile time or execution time macro quoting function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/compile-time-or-execution-time-macro-quoting-function/m-p/446604#M112075</link>
    <description>&lt;P&gt;&amp;nbsp;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When calling macro which macro quoting function should be used macro parameters?&amp;nbsp; In this example&amp;nbsp; both %nrstr and %nrbquote give the same result. Thanks !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro m (par);
   data a;
     x = "&amp;amp;par";
   run;
%mend m;
%m(%nrstr(A|B))

%macro m (par);
   data b;
     x = "&amp;amp;par";
   run;
%mend m;
%m(%nrbquote(A|B))&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 18 Mar 2018 19:06:59 GMT</pubDate>
    <dc:creator>SAS_inquisitive</dc:creator>
    <dc:date>2018-03-18T19:06:59Z</dc:date>
    <item>
      <title>compile time or execution time macro quoting function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compile-time-or-execution-time-macro-quoting-function/m-p/446604#M112075</link>
      <description>&lt;P&gt;&amp;nbsp;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When calling macro which macro quoting function should be used macro parameters?&amp;nbsp; In this example&amp;nbsp; both %nrstr and %nrbquote give the same result. Thanks !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro m (par);
   data a;
     x = "&amp;amp;par";
   run;
%mend m;
%m(%nrstr(A|B))

%macro m (par);
   data b;
     x = "&amp;amp;par";
   run;
%mend m;
%m(%nrbquote(A|B))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Mar 2018 19:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compile-time-or-execution-time-macro-quoting-function/m-p/446604#M112075</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2018-03-18T19:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: compile time or execution time macro quoting function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compile-time-or-execution-time-macro-quoting-function/m-p/446607#M112077</link>
      <description>&lt;P&gt;For this particular example, the answer is "none of the above".&amp;nbsp; This macro call should generate the same result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%m(A|B)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the first question should be whether macro quoting is necessary at all.&amp;nbsp; In this example, it isn't.&amp;nbsp; In general (in case your actual application is more complex than the one you have shown), the idea is that macro quoting removes special significance from characters that would impact the interpretation of the program.&amp;nbsp; Take the case where your macro defines a single parameter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro m (varname);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now this would be an illegal call to the macro since the comma is a significant character that identifies when one macro parameter ends and a new one begins:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%m (A, B)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get "A, B" to be interpreted as the value of a single macro parameter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%m (%str(A, B))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %STR function removes the special significance of the comma, and treats it as text instead.&amp;nbsp; Suppose the situation were more complex:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let list = A, B;&lt;/P&gt;
&lt;P&gt;%m (&amp;amp;list)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now the comma doesn't even appear in the macro call.&amp;nbsp; However, resolving &amp;amp;LIST generates a comma which causes the same problem as before.&amp;nbsp; That's when you need a macro function that quotes later on, as the macro executes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%m (%bquote(&amp;amp;list))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The differences between %str and %nrstr (and between %bquote and %nrbquote) are only a matter of which characters are impacted by quoting.&amp;nbsp; The NR in the function name quotes % and &amp;amp; in addition to all the other characters quoted by %str.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 19:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compile-time-or-execution-time-macro-quoting-function/m-p/446607#M112077</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-18T19:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: compile time or execution time macro quoting function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compile-time-or-execution-time-macro-quoting-function/m-p/446780#M112156</link>
      <description>&lt;P&gt;I would pick up %nrstr()&amp;nbsp; &amp;nbsp;%nrbquote() is generally for a macro variable .&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compile-time-or-execution-time-macro-quoting-function/m-p/446780#M112156</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-03-19T14:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: compile time or execution time macro quoting function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compile-time-or-execution-time-macro-quoting-function/m-p/446835#M112180</link>
      <description>I have inherited programs that have used %nrbquote  by default whether there is macro triggers (&amp;amp;, %) or not. So I was wondering %nrstr can be replaced by %nrbquote in macro call at all conditions.</description>
      <pubDate>Mon, 19 Mar 2018 15:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compile-time-or-execution-time-macro-quoting-function/m-p/446835#M112180</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2018-03-19T15:56:35Z</dc:date>
    </item>
  </channel>
</rss>

