<?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: IN operator in proc sql with macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql-with-macro/m-p/484124#M125640</link>
    <description>&lt;P&gt;You have no keyword parameters in your macro definition (only positional ones), but supply keyword parameters in the call. Make up your mind how you want to call your macro.&lt;/P&gt;</description>
    <pubDate>Sun, 05 Aug 2018 09:03:36 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-08-05T09:03:36Z</dc:date>
    <item>
      <title>IN operator in proc sql with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql-with-macro/m-p/484119#M125635</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;May you please look at the following code and tell what is wrong with it?&lt;/P&gt;&lt;P&gt;The error is&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: All positional parameters must precede keyword parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tbl;
input ID  branch;
cards;
1 100
2 100
3 200
4 300
5 400
6 500
7 500
8 500
9 500
10 500
;
run;

%macro rjoe(x,branchP);
PROC SQL;
	create table outcome_&amp;amp;x. as
	select *	   
	from tbl
	where branch in (&amp;amp;branchP.)
;
QUIT;
%mend;

%rjoe(x=1,branchP=100);
%rjoe(x=2,branchP=200);
%rjoe(x=3,branchP=300);
%rjoe(x=4,branchP=400);
%rjoe(x=5,branchP=500);
%rjoe(x=6,branchP=100 200 300 400 500);/*It is working well*/
%rjoe(x=6,branchP=100, 200, 300, 400, 500);/*It is  not working .why??*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 08:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql-with-macro/m-p/484119#M125635</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-05T08:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: IN operator in proc sql with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql-with-macro/m-p/484124#M125640</link>
      <description>&lt;P&gt;You have no keyword parameters in your macro definition (only positional ones), but supply keyword parameters in the call. Make up your mind how you want to call your macro.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 09:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql-with-macro/m-p/484124#M125640</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-05T09:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: IN operator in proc sql with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql-with-macro/m-p/484441#M125776</link>
      <description>&lt;P&gt;&lt;SPAN class="token macroname"&gt;%rjoe&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;x&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;branchP&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;100&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;200&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;300&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;400&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;500&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Has a major issue in that you defined the macro with two variables. But since the comma is the macro delimiter in a parameter list you have 4 extra parameters: 200 300 400 500.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Since the code you are using with the IN operator does &lt;STRONG&gt;not&lt;/STRONG&gt; require a comma then use&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token macroname"&gt;%rjoe&lt;/SPAN&gt;(x&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;,branchP&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;100 &lt;/SPAN&gt;&amp;nbsp;&lt;SPAN class="token number"&gt;200&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;300&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;400&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;500&lt;/SPAN&gt;);&lt;SPAN class="token comment"&gt;/&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token comment"&gt;The specific error you get comes from the macro parser. From the documentation: &lt;SPAN class="xis-noteGenText"&gt;Note: &lt;/SPAN&gt;You can define an unlimited number of parameters. If both &lt;STRONG&gt;positional and keyword&lt;/STRONG&gt; parameters appear in a macro definition, &lt;STRONG&gt;positional parameters must come first&lt;/STRONG&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token comment"&gt;I added emphasis. Since you had comma delimited items after the other x= and branch = the parser saw positional parameters after the keyword parameters. If you had used:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token comment"&gt;&lt;SPAN class="token macroname"&gt;%rjoe&lt;/SPAN&gt;(&lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;,&lt;SPAN class="token number"&gt;100&lt;/SPAN&gt;, &lt;SPAN class="token number"&gt;200&lt;/SPAN&gt;, &lt;SPAN class="token number"&gt;300&lt;/SPAN&gt;, &lt;SPAN class="token number"&gt;400&lt;/SPAN&gt;, &lt;SPAN class="token number"&gt;500&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token comment"&gt;You would have received an error of "more positional parameters found than defined" or similar.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 16:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql-with-macro/m-p/484441#M125776</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-06T16:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: IN operator in proc sql with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql-with-macro/m-p/484444#M125778</link>
      <description>&lt;P&gt;Commas are interpreted as delimiters of the arguments in the call to the macro. The %STR function allows the commas to be treated as text instead of delimeters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%rjoe(x=6,branchP=%str(100, 200, 300, 400, 500))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Aug 2018 17:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql-with-macro/m-p/484444#M125778</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-08-06T17:06:45Z</dc:date>
    </item>
  </channel>
</rss>

