<?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: Expected close parenthesis error in loop over macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Expected-close-parenthesis-error-in-loop-over-macro/m-p/369622#M88278</link>
    <description>&lt;P&gt;Agree, that bit looks fine.&amp;nbsp; Maybe there's a problematic macro call inside of %SomeMacro, or maybe your ColumnName variable has an unmatched open parenthesis in it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested your code with below, and worked fine:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro somemacro(columnName);
  proc print data=sashelp.class;
    var &amp;amp;columnName;
  run;
%mend somemacro;

data loopdata;
  input columnName $8.;
  cards;
sex
weight
height
;
run;

data _null_;
  set LoopData;
  call execute('%nrstr(%SomeMacro('||ColumnName||'))');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would try calling %SomeMacros manually (i.e., without CALL EXECUTE), and make sure it works.&amp;nbsp; Then I would look at all the values in ColumnName to check for any surprises.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2017 18:27:31 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2017-06-22T18:27:31Z</dc:date>
    <item>
      <title>Expected close parenthesis error in loop over macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expected-close-parenthesis-error-in-loop-over-macro/m-p/369614#M88276</link>
      <description>&lt;P&gt;I am getting a:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected close parenthesis after macro function invocation not found&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;fro this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_;
  set LoopData;
  call execute('%nrstr(%SomeMacro('||ColumnName||'))');
run;&lt;/PRE&gt;&lt;P&gt;Cannot see anything wrong. Any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 18:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expected-close-parenthesis-error-in-loop-over-macro/m-p/369614#M88276</guid>
      <dc:creator>csetzkorn</dc:creator>
      <dc:date>2017-06-22T18:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: Expected close parenthesis error in loop over macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expected-close-parenthesis-error-in-loop-over-macro/m-p/369622#M88278</link>
      <description>&lt;P&gt;Agree, that bit looks fine.&amp;nbsp; Maybe there's a problematic macro call inside of %SomeMacro, or maybe your ColumnName variable has an unmatched open parenthesis in it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tested your code with below, and worked fine:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro somemacro(columnName);
  proc print data=sashelp.class;
    var &amp;amp;columnName;
  run;
%mend somemacro;

data loopdata;
  input columnName $8.;
  cards;
sex
weight
height
;
run;

data _null_;
  set LoopData;
  call execute('%nrstr(%SomeMacro('||ColumnName||'))');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would try calling %SomeMacros manually (i.e., without CALL EXECUTE), and make sure it works.&amp;nbsp; Then I would look at all the values in ColumnName to check for any surprises.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 18:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expected-close-parenthesis-error-in-loop-over-macro/m-p/369622#M88278</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-06-22T18:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Expected close parenthesis error in loop over macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expected-close-parenthesis-error-in-loop-over-macro/m-p/369656#M88283</link>
      <description>Thanks I removed brackets from ColumnName because I thought exactly this. Turned out to be some legacy being commented out which screwed the code.</description>
      <pubDate>Thu, 22 Jun 2017 19:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expected-close-parenthesis-error-in-loop-over-macro/m-p/369656#M88283</guid>
      <dc:creator>csetzkorn</dc:creator>
      <dc:date>2017-06-22T19:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Expected close parenthesis error in loop over macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Expected-close-parenthesis-error-in-loop-over-macro/m-p/369663#M88284</link>
      <description>&lt;P&gt;Personally when using CALL EXECUTE() to generate macro calls I wrap the %NRSTR() macro function just around the macro name itself and leave the macro parameters without macro quoting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set LoopData;
  call execute(cats('%nrstr(%SomeMacro)(',ColumnName,')'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Are you sure that the value of ColumnName does not contain '()' characters?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 19:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Expected-close-parenthesis-error-in-loop-over-macro/m-p/369663#M88284</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-22T19:20:18Z</dc:date>
    </item>
  </channel>
</rss>

