<?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 CALL EXECUTE- ERROR: More positional parameters found than defined in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741274#M29123</link>
    <description>&lt;P&gt;Here are two easier things to try if you are just going to use the list of values with the IN operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First:&amp;nbsp; Get rid of the commas.&amp;nbsp; The IN operator in SAS is just as happy to use spaces instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE IDS in ('a111' 'a222' 'a333')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Second:&amp;nbsp; Include the parentheses in the parameter value.&amp;nbsp; That will protect the commas from being seen as marking new arguments.&amp;nbsp; Either put them in the macro variable value, or in the macro call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro get_dbdate(mbr_list);
... 
where ids in &amp;amp;mbr_list 
...
%mend;
...
%get_dbdata( ('a111','a222','a333') );
...
call execute(cats('%get_dbdata((',mbr_list,'))'));;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 13 May 2021 20:47:29 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-05-13T20:47:29Z</dc:date>
    <item>
      <title>macro CALL EXECUTE- ERROR: More positional parameters found than defined</title>
      <link>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741023#M29103</link>
      <description>&lt;P&gt;I wanted to iteratively pass list of variables in quotes separated by commas to a SQL WHERE “IN” &amp;nbsp;clause&lt;/P&gt;
&lt;P&gt;WHERE IDS in ('a111','a222','a333');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please check below working piece of SAS macro code, first approach invokes macro directly using %, it is working as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the second approach; macro invocation using CALL EXECUTE, I am not able to pass multiple parameters without wrapping up in quotes&lt;/P&gt;
&lt;P&gt;Else it will throw ERROR: More positional parameters found than defined&lt;/P&gt;
&lt;P&gt;But as workaround I am able to remove the additional quote using a dequote inside the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Can you suggest modification to CALL EXECUTE statement so that macro variable mbrlist receive values as 'a111','a222','a333' and not “'a111','a222','a333'”, &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;so that dequote statement is not needed, ie wrapping CALL executive parms or just macro parm with %NRSTR, %NRBQUOTE etc functions?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro get_dbdata(mbrlist)&amp;nbsp; ;
&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;=mbrlist;
&amp;nbsp;&amp;nbsp;&amp;nbsp; %let mbrlist_DQ=%sysfunc(dequote(&amp;amp;mbrlist.));
&amp;nbsp;&amp;nbsp;&amp;nbsp; %put &amp;amp;=mbrlist_DQ;
%MEND;



/* 1. Call macro direct */

%let mbrlst='a111','a222','a333';
%put &amp;amp;=mbrlst;
%get_dbdata(%nrstr(&amp;amp;mbrlst));


/* 2. Call macro using Call execute */

data qq;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&amp;nbsp;&amp;nbsp; set indata; */


&amp;nbsp;&amp;nbsp;&amp;nbsp; mbr_list="'b111','b222','b333'";
&amp;nbsp;&amp;nbsp;&amp;nbsp; put mbr_list=;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;call execute('%get_dbdata("' || strip(mbr_list) || '")'&amp;nbsp; );;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 May 2021 05:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741023#M29103</guid>
      <dc:creator>Ninan</dc:creator>
      <dc:date>2021-05-13T05:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: macro CALL EXECUTE- ERROR: More positional parameters found than defined</title>
      <link>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741027#M29105</link>
      <description>&lt;P&gt;You need to include the %NRSTR in the CALL EXECUTE.&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 06:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741027#M29105</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-05-13T06:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: macro CALL EXECUTE- ERROR: More positional parameters found than defined</title>
      <link>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741082#M29114</link>
      <description>&lt;P&gt;It looks like you intend to use the list in your macro, something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where ids in (&amp;amp;mbr_list)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As long as you don't add %NRSTR in the wrong place, you don't need to pass the list of values as a macro parameter.&amp;nbsp; Instead, bypass all parameters:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ata qq;
    /*   set indata; */
    mbr_list="'b111','b222','b333'";
    put mbr_list=;
    call symputx('mbr_list', mbr_list);
    call execute('%get_dbdata');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Within the definition of %get_dbdata, you can still use the WHERE clause that refers to &amp;amp;mbr_list.&amp;nbsp; It's just not a macro parameter anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that there is a tricky timing issue here, that works for this problem.&amp;nbsp; On each observation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;First, CALL SYMPUTX replaces &amp;amp;mbr_list&lt;/LI&gt;
&lt;LI&gt;Then CALL EXECUTE replaces references to &amp;amp;mbr_list within %get_dbdata with the current value of &amp;amp;mbr_list&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 12:43:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741082#M29114</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-05-13T12:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: macro CALL EXECUTE- ERROR: More positional parameters found than defined</title>
      <link>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741085#M29115</link>
      <description>&lt;P&gt;I have tried %NRSTR in multiple combinations before but it was throwing different errors, may be because of unbalanced quotes, commas, and brackets&lt;/P&gt;
&lt;P&gt;But rethinking with fresh mind it is working now -&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call execute('%get_dbdata(%NRSTR(' || strip(mbr_list) || '))'&amp;nbsp; );;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you Kurt&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 12:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741085#M29115</guid>
      <dc:creator>Ninan</dc:creator>
      <dc:date>2021-05-13T12:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: macro CALL EXECUTE- ERROR: More positional parameters found than defined</title>
      <link>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741088#M29116</link>
      <description>&lt;P&gt;To add the %NRSTR in the CALL EXECUTE wrap it in %NRSTR().&lt;/P&gt;
&lt;PRE&gt;3110  data qq;
3111    mbr_list="'b111','b222','b333'";
3112    put mbr_list=;
3113    call execute(cats('%get_dbdata(%nrstr(%nrstr)(',mbr_list,'))'));
3114  run;

mbr_list='b111','b222','b333'
MBRLIST=%nrstr('b111','b222','b333')
MBRLIST_DQ='b111','b222','b333'
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 13:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741088#M29116</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-13T13:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: macro CALL EXECUTE- ERROR: More positional parameters found than defined</title>
      <link>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741116#M29121</link>
      <description>Thank you for your response, this is an alternate solution to avoid the complexities of concatenating different parameter while calling the macro.</description>
      <pubDate>Thu, 13 May 2021 13:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741116#M29121</guid>
      <dc:creator>Ninan</dc:creator>
      <dc:date>2021-05-13T13:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: macro CALL EXECUTE- ERROR: More positional parameters found than defined</title>
      <link>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741244#M29122</link>
      <description>Responses below from Astounding and Kurt are solutions &lt;BR /&gt;Response from Tom about using nested functions be considered as extension of what we have discussed here, &lt;BR /&gt;&lt;BR /&gt;now this thread has many use-cases to explore for SAS MACRO learner!!&lt;BR /&gt;Thanks everyone for all your replies.&lt;BR /&gt;</description>
      <pubDate>Thu, 13 May 2021 19:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741244#M29122</guid>
      <dc:creator>Ninan</dc:creator>
      <dc:date>2021-05-13T19:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: macro CALL EXECUTE- ERROR: More positional parameters found than defined</title>
      <link>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741274#M29123</link>
      <description>&lt;P&gt;Here are two easier things to try if you are just going to use the list of values with the IN operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First:&amp;nbsp; Get rid of the commas.&amp;nbsp; The IN operator in SAS is just as happy to use spaces instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE IDS in ('a111' 'a222' 'a333')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Second:&amp;nbsp; Include the parentheses in the parameter value.&amp;nbsp; That will protect the commas from being seen as marking new arguments.&amp;nbsp; Either put them in the macro variable value, or in the macro call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro get_dbdate(mbr_list);
... 
where ids in &amp;amp;mbr_list 
...
%mend;
...
%get_dbdata( ('a111','a222','a333') );
...
call execute(cats('%get_dbdata((',mbr_list,'))'));;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 May 2021 20:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/macro-CALL-EXECUTE-ERROR-More-positional-parameters-found-than/m-p/741274#M29123</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-13T20:47:29Z</dc:date>
    </item>
  </channel>
</rss>

