<?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: Give multiple value to macro parameter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791565#M253574</link>
    <description>&lt;P&gt;if you need commas in "carlist" chnge the macro to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cardataset (carlst=());
data new;
	set sashelp.cars;
	if make in &amp;amp;carlst; /* no brackets*/
run;
%mend cardataset;


%cardataset(carlst=("Audi","BMW","Ford")) /* brackets will mask commas */	&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;other option would be to use PARMBUFF and SYSPBUFF(&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0dwee153ed7b2n1wl471mgtczle.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0dwee153ed7b2n1wl471mgtczle.htm&lt;/A&gt;) in macro definition:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;%macro cardataset () / PARMBUFF;
data new;
	set sashelp.cars;
	if make in &amp;amp;syspbuff.;
run;
%mend cardataset;
&lt;BR /&gt;
%cardataset("Audi","BMW","Ford")	&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jan 2022 18:45:53 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2022-01-21T18:45:53Z</dc:date>
    <item>
      <title>Give multiple value to macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791534#M253551</link>
      <description>&lt;P&gt;I want to pass multiple value to one macro parameter.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro cardataset (carlst=);
data new;
	set sashelp.cars;
	if make in(&amp;amp;carlst);
run;
%mend cardataset;
&lt;BR /&gt;
%cardataset(carlst="Audi","BMW","Ford")	&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I am trying to run above macro, I get following error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class=""&gt;Statement is not valid or it is used out of proper order. ERROR: All positional parameters must precede keyword parameters.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 17:42:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791534#M253551</guid>
      <dc:creator>surajmetha55</dc:creator>
      <dc:date>2022-01-21T17:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Give multiple value to macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791538#M253552</link>
      <description>Remove the comma's from the list - they're not needed either in this use case.&lt;BR /&gt;&lt;BR /&gt;%cardataset(carlst="Audi" "BMW" "Ford")</description>
      <pubDate>Fri, 21 Jan 2022 17:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791538#M253552</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-21T17:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Give multiple value to macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791541#M253553</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;%cardataset(carlst="Audi" "BMW" "Ford")	&lt;/PRE&gt;
&lt;P&gt;The IN operator in a data step has not needed a comma between values since SAS 9.3 (or maybe 9.2, it has been a while ago anyway).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The comma is the delimiter between macro parameters.&lt;/P&gt;
&lt;P&gt;When you used&lt;/P&gt;
&lt;PRE&gt;%cardataset(carlst="Audi","BMW","Ford")	&lt;/PRE&gt;
&lt;P&gt;Then your carlst value was only "Audi" because of the comma. "BMW" and "Ford" were considered to be positional parameters that were 1) not defined in the macro definition and 2) since they did not use the Keyword parameter such as Parm="BMW" were considered positional (which order they appear in the call assigns the value). Positional parameters, since they do rely on the order, must be defined before the keyword parameters. One reason for this requirement is that Keyword parameters, such as Carlst= could have no assigned value (which is useful if it normally has a default that you only override sometimes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 18:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791541#M253553</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-21T18:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Give multiple value to macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791545#M253556</link>
      <description>&lt;P&gt;Try&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%cardataset(carlst=%nrstr("Audi","BMW","Ford"))	&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jan 2022 18:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791545#M253556</guid>
      <dc:creator>rudfaden3</dc:creator>
      <dc:date>2022-01-21T18:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Give multiple value to macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791565#M253574</link>
      <description>&lt;P&gt;if you need commas in "carlist" chnge the macro to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cardataset (carlst=());
data new;
	set sashelp.cars;
	if make in &amp;amp;carlst; /* no brackets*/
run;
%mend cardataset;


%cardataset(carlst=("Audi","BMW","Ford")) /* brackets will mask commas */	&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;other option would be to use PARMBUFF and SYSPBUFF(&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0dwee153ed7b2n1wl471mgtczle.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0dwee153ed7b2n1wl471mgtczle.htm&lt;/A&gt;) in macro definition:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;%macro cardataset () / PARMBUFF;
data new;
	set sashelp.cars;
	if make in &amp;amp;syspbuff.;
run;
%mend cardataset;
&lt;BR /&gt;
%cardataset("Audi","BMW","Ford")	&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 18:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791565#M253574</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-01-21T18:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Give multiple value to macro parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791567#M253575</link>
      <description>&lt;P&gt;No need to modify the macro.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1559
1560  %cardataset(carlst=("Audi","BMW","Ford"))
MPRINT(CARDATASET):   data new;
MPRINT(CARDATASET):   set sashelp.cars;
MPRINT(CARDATASET):   if make in(("Audi","BMW","Ford"));
MPRINT(CARDATASET):   run;

NOTE: There were 428 observations read from the data set SASHELP.CARS.
NOTE: The data set WORK.NEW has 62 observations and 15 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.04 seconds
&lt;/PRE&gt;
&lt;P&gt;IN operator does not seem to mind extra random &lt;STRONG&gt;parentheses&lt;/STRONG&gt; (although it would complain if actually included &lt;STRONG&gt;brackets&lt;/STRONG&gt; like [ ] or { } ).&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 18:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Give-multiple-value-to-macro-parameter/m-p/791567#M253575</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-21T18:48:58Z</dc:date>
    </item>
  </channel>
</rss>

