<?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: how to solve macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751716#M236679</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally your code should work, as shown in the log below:&lt;/P&gt;
&lt;PRE&gt;1    %let e=""xyz"";
2    %put %substr(&amp;amp;e,3,2);
xy&lt;/PRE&gt;
&lt;P&gt;(Note that the four quotation marks got part of the macro variable value.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the error message is most likely the result of submitting different code &lt;EM&gt;before&lt;/EM&gt;&amp;nbsp;(see your log).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Examples include:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Missing semicolon after the %LET statement (see line 1 below). In this situation submit a single semicolon (line 3) to repair the damage. Then submit the %PUT statement again (line 4) and&amp;nbsp;add the missing semicolon in the code.&lt;BR /&gt;
&lt;PRE&gt;1    %let e=""xyz""
2    %put %substr(&amp;amp;e,3,2);
&lt;FONT color="#FF0000"&gt;ERROR: Open code statement recursion detected.&lt;/FONT&gt;
3    ;
4    %put %substr(&amp;amp;e,3,2);
xy&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;UL&gt;
&lt;LI&gt;Unbalanced quotes in the %LET statement&amp;nbsp;(see line 1 below). In this situation submit the missing quotation mark followed by a semicolon (line 3) to repair the damage. Then add the missing quotation mark in the code and submit both statements again (lines 4, 5).&lt;BR /&gt;
&lt;PRE&gt;1    %let e=""xyz";
2    %put %substr(&amp;amp;e,3,2);
&lt;FONT color="#FF0000"&gt;ERROR: Open code statement recursion detected.&lt;/FONT&gt;
3    ";
4    %let e=""xyz"";
5    %put %substr(&amp;amp;e,3,2);
xy&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Unbalanced quote(s) in the expression in the %PUT statement&amp;nbsp;(&lt;EM&gt;after resolution&lt;/EM&gt;, see line 2 below) and then trying to submit one or both of the statements again (line 3) because the %PUT statement "didn't work." In this situation, similar to the previous bullet point, submit a quotation mark followed by a semicolon (line 4) to repair the damage. Then submit the corrected %PUT statement so that it doesn't create an &lt;EM&gt;unprotected&lt;/EM&gt;, unbalanced quotation mark (line 5 &lt;EM&gt;or&lt;/EM&gt; line 6). The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n02zgr13otvtqin1f0gpvfcdhg3r.htm" target="_blank" rel="noopener"&gt;%QSUBSTR function&lt;/A&gt;&amp;nbsp;(line 6) masks the quotation mark and thus avoids the problem.&lt;BR /&gt;
&lt;PRE&gt;1    %let e=""xyz"";
2    %put %substr(&amp;amp;e,1,1);
&lt;FONT color="#FF0000"&gt;ERROR: Open code statement recursion detected.&lt;/FONT&gt;
3    %put %substr(&amp;amp;e,1,1);
4    ";
";"
5    %put %substr(&amp;amp;e,&lt;STRONG&gt;3&lt;/STRONG&gt;,&lt;STRONG&gt;2&lt;/STRONG&gt;);
xy
6    %put %&lt;STRONG&gt;q&lt;/STRONG&gt;substr(&amp;amp;e,1,1);
"&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Fri, 02 Jul 2021 12:46:17 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-07-02T12:46:17Z</dc:date>
    <item>
      <title>how to solve macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751657#M236648</link>
      <description>&lt;P&gt;%let e=""xyz"" ;&lt;BR /&gt;%put %substr(&amp;amp;e,3,2);&lt;/P&gt;
&lt;P&gt;when I am executing above programming I am getting error like&lt;/P&gt;
&lt;P&gt;ERROR: Open code statement recursion detected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 09:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751657#M236648</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2021-07-02T09:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to solve macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751662#M236652</link>
      <description>&lt;P&gt;You do not need the quotation marks around xyxz&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that the range specified is out of bounds. Try this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let e=xyz;&lt;BR /&gt;%put %substr(&amp;amp;e,2,1);&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 09:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751662#M236652</guid>
      <dc:creator>AzizAA</dc:creator>
      <dc:date>2021-07-02T09:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to solve macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751676#M236659</link>
      <description>Don't remove quotations&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Jul 2021 10:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751676#M236659</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2021-07-02T10:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to solve macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751696#M236668</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Don't remove quotations&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;meaning?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 11:02:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751696#M236668</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-02T11:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to solve macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751699#M236669</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Don't remove quotations&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Quoting values when assigning macro-variables is a bad idea in most cases i have seen in the last decade. It is almost always better to use the quotes when you want the value of the variable inserted into sas code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 11:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751699#M236669</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-02T11:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to solve macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751702#M236670</link>
      <description>&lt;P&gt;First, figure out what you are working with.&amp;nbsp; Try this test initially:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put **&amp;amp;e**;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 11:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751702#M236670</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-07-02T11:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to solve macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751716#M236679</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally your code should work, as shown in the log below:&lt;/P&gt;
&lt;PRE&gt;1    %let e=""xyz"";
2    %put %substr(&amp;amp;e,3,2);
xy&lt;/PRE&gt;
&lt;P&gt;(Note that the four quotation marks got part of the macro variable value.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the error message is most likely the result of submitting different code &lt;EM&gt;before&lt;/EM&gt;&amp;nbsp;(see your log).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Examples include:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Missing semicolon after the %LET statement (see line 1 below). In this situation submit a single semicolon (line 3) to repair the damage. Then submit the %PUT statement again (line 4) and&amp;nbsp;add the missing semicolon in the code.&lt;BR /&gt;
&lt;PRE&gt;1    %let e=""xyz""
2    %put %substr(&amp;amp;e,3,2);
&lt;FONT color="#FF0000"&gt;ERROR: Open code statement recursion detected.&lt;/FONT&gt;
3    ;
4    %put %substr(&amp;amp;e,3,2);
xy&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;UL&gt;
&lt;LI&gt;Unbalanced quotes in the %LET statement&amp;nbsp;(see line 1 below). In this situation submit the missing quotation mark followed by a semicolon (line 3) to repair the damage. Then add the missing quotation mark in the code and submit both statements again (lines 4, 5).&lt;BR /&gt;
&lt;PRE&gt;1    %let e=""xyz";
2    %put %substr(&amp;amp;e,3,2);
&lt;FONT color="#FF0000"&gt;ERROR: Open code statement recursion detected.&lt;/FONT&gt;
3    ";
4    %let e=""xyz"";
5    %put %substr(&amp;amp;e,3,2);
xy&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;Unbalanced quote(s) in the expression in the %PUT statement&amp;nbsp;(&lt;EM&gt;after resolution&lt;/EM&gt;, see line 2 below) and then trying to submit one or both of the statements again (line 3) because the %PUT statement "didn't work." In this situation, similar to the previous bullet point, submit a quotation mark followed by a semicolon (line 4) to repair the damage. Then submit the corrected %PUT statement so that it doesn't create an &lt;EM&gt;unprotected&lt;/EM&gt;, unbalanced quotation mark (line 5 &lt;EM&gt;or&lt;/EM&gt; line 6). The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n02zgr13otvtqin1f0gpvfcdhg3r.htm" target="_blank" rel="noopener"&gt;%QSUBSTR function&lt;/A&gt;&amp;nbsp;(line 6) masks the quotation mark and thus avoids the problem.&lt;BR /&gt;
&lt;PRE&gt;1    %let e=""xyz"";
2    %put %substr(&amp;amp;e,1,1);
&lt;FONT color="#FF0000"&gt;ERROR: Open code statement recursion detected.&lt;/FONT&gt;
3    %put %substr(&amp;amp;e,1,1);
4    ";
";"
5    %put %substr(&amp;amp;e,&lt;STRONG&gt;3&lt;/STRONG&gt;,&lt;STRONG&gt;2&lt;/STRONG&gt;);
xy
6    %put %&lt;STRONG&gt;q&lt;/STRONG&gt;substr(&amp;amp;e,1,1);
"&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 02 Jul 2021 12:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-solve-macro-variable/m-p/751716#M236679</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-02T12:46:17Z</dc:date>
    </item>
  </channel>
</rss>

