<?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 Resolve Macro Variable which is argument of a Macro Function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Macro-Variable-which-is-argument-of-a-Macro-Function/m-p/364814#M86561</link>
    <description>&lt;P&gt;I have been struggling with an issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %scan(%str(arg1=A,arg2=B,arg3=C),1);

%let string = arg1=A,arg2=B,arg3=C;

%put %scan(%str(&amp;amp;string),1);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first &lt;STRONG&gt;%put&lt;/STRONG&gt; statement writes &lt;STRONG&gt;arg1=A&lt;/STRONG&gt; in the log as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second &lt;STRONG&gt;%put&lt;/STRONG&gt; statement gives a warning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;WARNING: Argument 2 to macro function %SCAN is out of range.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I force the &lt;STRONG&gt;%put&lt;/STRONG&gt; statement to first resolve the macro variable &lt;STRONG&gt;&amp;amp;string&lt;/STRONG&gt; to &lt;STRONG&gt;arg1=A,arg2=B,arg3=C&lt;/STRONG&gt; and then execute the %put statement?&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jun 2017 03:23:29 GMT</pubDate>
    <dc:creator>arnouxvr</dc:creator>
    <dc:date>2017-06-07T03:23:29Z</dc:date>
    <item>
      <title>Resolve Macro Variable which is argument of a Macro Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Macro-Variable-which-is-argument-of-a-Macro-Function/m-p/364814#M86561</link>
      <description>&lt;P&gt;I have been struggling with an issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %scan(%str(arg1=A,arg2=B,arg3=C),1);

%let string = arg1=A,arg2=B,arg3=C;

%put %scan(%str(&amp;amp;string),1);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first &lt;STRONG&gt;%put&lt;/STRONG&gt; statement writes &lt;STRONG&gt;arg1=A&lt;/STRONG&gt; in the log as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second &lt;STRONG&gt;%put&lt;/STRONG&gt; statement gives a warning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;WARNING: Argument 2 to macro function %SCAN is out of range.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I force the &lt;STRONG&gt;%put&lt;/STRONG&gt; statement to first resolve the macro variable &lt;STRONG&gt;&amp;amp;string&lt;/STRONG&gt; to &lt;STRONG&gt;arg1=A,arg2=B,arg3=C&lt;/STRONG&gt; and then execute the %put statement?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 03:23:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Macro-Variable-which-is-argument-of-a-Macro-Function/m-p/364814#M86561</guid>
      <dc:creator>arnouxvr</dc:creator>
      <dc:date>2017-06-07T03:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Resolve Macro Variable which is argument of a Macro Function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolve-Macro-Variable-which-is-argument-of-a-Macro-Function/m-p/364816#M86563</link>
      <description>&lt;P&gt;this should work as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %STR and %NRSTR functions mask a character string during compilation of a macro or macro language statement. They mask the following special characters and mnemonic operators:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to make it work &amp;nbsp;during execution use %bquote&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%put %scan(%str(arg1=A,arg2=B,arg3=C),1);
/*complilation*/
%let string = %str(arg1=A,arg2=B,arg3=C);
%put %scan(&amp;amp;string,1);&lt;BR /&gt;/*bquote During execution*/&lt;BR /&gt;%let string9 = arg1=A,arg2=B,arg3=C;&lt;BR /&gt;%put %scan(%bquote(&amp;amp;string9),1);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 03:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolve-Macro-Variable-which-is-argument-of-a-Macro-Function/m-p/364816#M86563</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-07T03:42:53Z</dc:date>
    </item>
  </channel>
</rss>

