<?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: quoted comma delimeted are argument in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quoted-comma-delimeted-are-argument/m-p/812798#M320709</link>
    <description>Thank you!&lt;BR /&gt;&lt;BR /&gt;I tried your second suggestion just right after I posted my question:&lt;BR /&gt;.. where code in &amp;amp;list.;&lt;BR /&gt;..&lt;BR /&gt;%generate_data(test, (‘a’, ‘b’, ‘c’));&lt;BR /&gt;&lt;BR /&gt;I learned more from your reply such as the us of %str and %dequote</description>
    <pubDate>Wed, 11 May 2022 20:25:28 GMT</pubDate>
    <dc:creator>jffeudo86</dc:creator>
    <dc:date>2022-05-11T20:25:28Z</dc:date>
    <item>
      <title>quoted comma delimeted are argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quoted-comma-delimeted-are-argument/m-p/812491#M320582</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;How do I pass a quoted delimited argument to a macro?&amp;nbsp; Below is a sample code to show the issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro generate_data(ds, list);&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table &amp;amp;ds. as&lt;/P&gt;&lt;P&gt;select * from some_table&lt;/P&gt;&lt;P&gt;where code in (&amp;amp;list.);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%mend generate_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%generate_data(test, "'a', 'b', 'c'");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I pass/format the 2nd argument 'a', 'b', 'c'? if I pass it without the double quotes at either ends, it will be treated as more than 1 argument.&amp;nbsp; Basically the proc sql in side the macro would resolve to:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table test as&lt;/P&gt;&lt;P&gt;select * from some_table&lt;/P&gt;&lt;P&gt;where code in ('a', 'b', 'c');&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 20:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quoted-comma-delimeted-are-argument/m-p/812491#M320582</guid>
      <dc:creator>jffeudo86</dc:creator>
      <dc:date>2022-05-10T20:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: quoted comma delimeted are argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quoted-comma-delimeted-are-argument/m-p/812493#M320583</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro generate_data(ds, list);
proc sql;
create table &amp;amp;ds. as
select * from some_table
where code in &amp;amp;list.; /* &amp;lt;- drop () */
quit;
%mend generate_data;

%generate_data(test, ('a', 'b', 'c'))&amp;nbsp;/* &amp;lt;- add() */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 May 2022 20:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quoted-comma-delimeted-are-argument/m-p/812493#M320583</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-05-10T20:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: quoted comma delimeted are argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quoted-comma-delimeted-are-argument/m-p/812494#M320584</link>
      <description>&lt;P&gt;&lt;STRONG&gt;The easiest way is to not type the commas.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The IN operator does not care if you use commas or spaces in the list of values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%generate_data(test, 'a' 'b' 'c');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you use actual quotes then remove them when generating the code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where code in (%sysfunc(dequote(&amp;amp;list.)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could remove the parentheses from the macro code and add them in the call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
where code in &amp;amp;list.;
...
%generate_data(test, ('a','b' 'c'));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could use macro quoting in the call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%generate_data(test, %str('a','b' 'c'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 21:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quoted-comma-delimeted-are-argument/m-p/812494#M320584</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-05-11T21:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: quoted comma delimeted are argument</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quoted-comma-delimeted-are-argument/m-p/812798#M320709</link>
      <description>Thank you!&lt;BR /&gt;&lt;BR /&gt;I tried your second suggestion just right after I posted my question:&lt;BR /&gt;.. where code in &amp;amp;list.;&lt;BR /&gt;..&lt;BR /&gt;%generate_data(test, (‘a’, ‘b’, ‘c’));&lt;BR /&gt;&lt;BR /&gt;I learned more from your reply such as the us of %str and %dequote</description>
      <pubDate>Wed, 11 May 2022 20:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quoted-comma-delimeted-are-argument/m-p/812798#M320709</guid>
      <dc:creator>jffeudo86</dc:creator>
      <dc:date>2022-05-11T20:25:28Z</dc:date>
    </item>
  </channel>
</rss>

