<?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: adding a list of values as a parameter in a macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614863#M18665</link>
    <description>&lt;P&gt;If you are going to do such things frequently you may want to investigate the macro option PARMBUFF as well.&lt;/P&gt;
&lt;P&gt;My online help even shows the PARMBUFF used with a comma delimited list.&lt;/P&gt;
&lt;P&gt;If you use PARMBUFF with other parameters the PARMBUFF values must be the last parameter passed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will likely still need to parse/loop over the values for some uses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might try:&lt;/P&gt;
&lt;PRE&gt;%macro test /parmbuff;

data analysis;
     set file;
     where numbers in &amp;amp;syspbuff.;
run;

%mend;

%test (100, 101, 102)&lt;/PRE&gt;
&lt;P&gt;Note that the () are part of the parameter used this way. Also the Parmbuff option populates a special macro variable SYSPBUFF.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jan 2020 21:29:10 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-01-02T21:29:10Z</dc:date>
    <item>
      <title>adding a list of values as a parameter in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614810#M18642</link>
      <description>&lt;P&gt;I'm looking to enter a list of values as a parameter in a macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(list_of_values);

data analysis;
&amp;nbsp; &amp;nbsp; &amp;nbsp;set file;
     where numbers in (&amp;amp;list_of_values);
run;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So then I can enter something like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%test((100,101,102))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;it's not always 3 numbers, it could also be 2 or 4. the list of values is also not the only parameter. I have some more in my code but the list would be one of them&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 17:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614810#M18642</guid>
      <dc:creator>Jens89</dc:creator>
      <dc:date>2020-01-02T17:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: adding a list of values as a parameter in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614813#M18645</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283672"&gt;@Jens89&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can replace commas by spaces in the in operator parenthesis.&lt;/P&gt;
&lt;P&gt;I have added the input dataset as another parameter to show you how to write the code :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(list_of_values,dataset);

data analysis;
     set &amp;amp;dataset;
where numbers in (&amp;amp;list_of_values);
run;

%mend;
 
%test(100 101 102, file)&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;You can also use the %str function if you want to mask commas:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%test(%str(100 101 102),file)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Jan 2020 17:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614813#M18645</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-02T17:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: adding a list of values as a parameter in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614814#M18646</link>
      <description>&lt;P&gt;that's beautiful! thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 17:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614814#M18646</guid>
      <dc:creator>Jens89</dc:creator>
      <dc:date>2020-01-02T17:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: adding a list of values as a parameter in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614815#M18647</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283672"&gt;@Jens89&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 17:38:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614815#M18647</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-01-02T17:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: adding a list of values as a parameter in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614816#M18648</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283672"&gt;@Jens89&lt;/a&gt;&amp;nbsp; &amp;nbsp;just quote the values to make the macro processor treat the commas as text rather than a separator of positional parameters or use keyword parameters with =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%test&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(%bquote&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&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;101&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;102&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%test&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(list_of_values=&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;101&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;102&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 17:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614816#M18648</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-02T17:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: adding a list of values as a parameter in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614863#M18665</link>
      <description>&lt;P&gt;If you are going to do such things frequently you may want to investigate the macro option PARMBUFF as well.&lt;/P&gt;
&lt;P&gt;My online help even shows the PARMBUFF used with a comma delimited list.&lt;/P&gt;
&lt;P&gt;If you use PARMBUFF with other parameters the PARMBUFF values must be the last parameter passed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will likely still need to parse/loop over the values for some uses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might try:&lt;/P&gt;
&lt;PRE&gt;%macro test /parmbuff;

data analysis;
     set file;
     where numbers in &amp;amp;syspbuff.;
run;

%mend;

%test (100, 101, 102)&lt;/PRE&gt;
&lt;P&gt;Note that the () are part of the parameter used this way. Also the Parmbuff option populates a special macro variable SYSPBUFF.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 21:29:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/adding-a-list-of-values-as-a-parameter-in-a-macro/m-p/614863#M18665</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-02T21:29:10Z</dc:date>
    </item>
  </channel>
</rss>

