<?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: Can you use a list of items in a macrovariable in  a where statement and in operator? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710168#M218566</link>
    <description>&lt;P&gt;Note that the IN operator does not need commas.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jan 2021 14:19:58 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-01-08T14:19:58Z</dc:date>
    <item>
      <title>Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710159#M218559</link>
      <description>&lt;P&gt;there have been many occasions where i've wanted to be able to do this, but have not been able to figure it out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given the following table and code to select the values of column C into a macrovariable "foods" separated by a space ( or really any delimiter).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TestTable;
	input A $ B C $;
	datalines;
Mitch 10 milk
Ed 14 tuna
Phil 45 bread
Bonnie 17 butter
;
run;

proc sql noprint;
	select C into :foods
		separated by ' '
	from TestTable;
quit;

%PUT foods=&amp;amp;foods.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a way to use that macrovariable in an in operator, such as the following?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	create table RandomTable1 as
		select * from RandomTable2
			where RandomColumn in ("milk" "tuna" "bread" "butter");
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With the values of the macrovariable as the values of the in operator?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 13:45:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710159#M218559</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-01-08T13:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710160#M218560</link>
      <description>Please ignore my misspelling of Where  in the title &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 08 Jan 2021 13:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710160#M218560</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-01-08T13:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710161#M218561</link>
      <description>&lt;P&gt;I don't recommend it, but yes, you can do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if you can use this as a template&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TestTable;
	input A $ B C $;
	datalines;
Mitch 10 milk
Ed 14 tuna
Phil 45 bread
Bonnie 17 butter
;
run;

proc sql noprint;
	select quote(compress(C)) into :foods
		separated by ', '
	from TestTable
   where C in ("milk", "tuna");
quit;

%PUT foods=&amp;amp;foods.;

proc sql noprint;
	create table want as
		select * from TestTable
			where C in (&amp;amp;foods.);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jan 2021 13:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710161#M218561</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-08T13:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710162#M218562</link>
      <description>&lt;P&gt;If you intend to use the macro variable in that way then include quotes in the value so you can simply use the macro variable to replace the hardcoded list of string literals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select distinct quote(trim(C)) into :foods separated by ' ' from TestTable;
...
where RandomColumn in (&amp;amp;foods)
...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jan 2021 13:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710162#M218562</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T13:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710163#M218563</link>
      <description>&lt;P&gt;Don't use COMPRESS() on the strings.&amp;nbsp; If they have any leading or embedded spaces then the resulting quoted strings will not match the values in the data.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 13:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710163#M218563</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T13:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710164#M218564</link>
      <description>&lt;P&gt;And if you use a comma as separator, you can use the macro variable with the IN operator &lt;EM&gt;and&lt;/EM&gt; in a WHEN statement in a data step SELECT block.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 14:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710164#M218564</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-08T14:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a where statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710168#M218566</link>
      <description>&lt;P&gt;Note that the IN operator does not need commas.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 14:19:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710168#M218566</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T14:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710174#M218568</link>
      <description>&lt;P&gt;You have a delimited list of items in a macro variable.&amp;nbsp; To use it with in IN operator, you need to add quote marks around each item (and may want to add a comma delimiter, for fun).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm a big fan of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12477"&gt;@RichardDeVen&lt;/a&gt;&amp;nbsp;'s utitly macro %seplist:&amp;nbsp;&lt;A href="https://www.devenezia.com/downloads/sas/macros/index.php?m=seplist" target="_blank"&gt;https://www.devenezia.com/downloads/sas/macros/index.php?m=seplist&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given a delimited list of items, it will add quotes (or whatever you want) around each item, change the delimiter, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1
2    %let foods=milk tuna bread butter ;
3
4    %put %seplist(&amp;amp;foods,nest=QQ,dlm=%str(,)) ;
"milk","tuna","bread","butter"
&lt;/PRE&gt;
&lt;P&gt;You can use like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	create table RandomTable1 as
		select * from RandomTable2
			where RandomColumn in (%seplist(&amp;amp;foods,nest=QQ,dlm=%str(,)));
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally I like to keep my macro variable lists without quote marks, and either space-delimited or pipe-delimited.&amp;nbsp; %SepList makes it easy to change delimiters or add quote marks when needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 14:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710174#M218568</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-01-08T14:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710182#M218570</link>
      <description>&lt;P&gt;Soon after posting I had an idea. And wrote a quick macro to add quotes around each of the values in the macrovariable.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far it seems to work correctly. With the constraint that the values be space delimited, with no internal spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*InVars must be space separated with no internal spaces in the values;
*VarName is Name of Global Variable ouputted, with quotes around each value.;
%MACRO K(VarName,InVars);
	%LET MVar1=;

	%DO J=1 %TO %SYSFUNC(CountW(&amp;amp;InVars.));
		%LET JJ=%SCAN(&amp;amp;InVars.,&amp;amp;J.);
		%LET quote&amp;amp;J.="&amp;amp;JJ.";
		%LET MVar1=&amp;amp;MVar1. &amp;amp;&amp;amp;quote&amp;amp;J.;
	%END;

	%GLOBAL &amp;amp;VarName.;
	%LET &amp;amp;VarName.=&amp;amp;MVar1.;
	%PUT &amp;amp;Varname.=&amp;amp;MVar1.;
%MEND K;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jan 2021 15:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710182#M218570</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-01-08T15:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710194#M218574</link>
      <description>&lt;P&gt;Looks good.&amp;nbsp; Make sure to define your local macros using %LOCAL statement so that programs that call that macro don't get supprised when the value their macro variables named MVAR1 and JJ and the others you are creating get changed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also look into making it a "function" macro.&amp;nbsp; Like the one mentioned above. Or this one:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasutils/macros/blob/master/qlist.sas" target="_blank"&gt;https://github.com/sasutils/macros/blob/master/qlist.sas&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 15:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710194#M218574</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T15:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a where statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710216#M218590</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Note that the IN operator does not need commas.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But it accepts them, while the WHEN statement &lt;EM&gt;requires&lt;/EM&gt; them. So I always use commas, as I've found that I often convert IF/THEN/ELSE statements with an IN operator to SELECT blocks.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 16:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710216#M218590</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-08T16:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710242#M218603</link>
      <description>&lt;P&gt;Arent macrovariables created within a macro local to that macro by default?&amp;nbsp; With any other macrovariables outside that macro unaffected, regardless of having the same name?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 18:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710242#M218603</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-01-08T18:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710246#M218605</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Macro variables created within a macro are only local to that macro&lt;STRONG&gt; if the macro variable does not already exist.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If the macro variable with that name already exists (either GLOBAL or in the local scope of another macro that has called this one) then that macro variable is used.&lt;/P&gt;
&lt;P&gt;The purpose of the %LOCAL statement is to insure that your macro is not changing macro variables previously defined.&amp;nbsp; So to avoid unwanted side effects of running the macro.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 18:13:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710246#M218605</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-08T18:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710248#M218607</link>
      <description>&lt;P&gt;Try this code:&lt;/P&gt;
&lt;PRE&gt;%macro prob(x=);
%do i = 1 %to &amp;amp;x;
  %put Writing i in Prob: &amp;amp;i;
%end;
%mend;
%macro driver(n=);
%do i= 1 %to &amp;amp;n;
   %prob(x=3)

   %put Writing i in Driver: &amp;amp;i.;
%end;
%mend;

%driver(n=2)&lt;/PRE&gt;
&lt;P&gt;Then add a %local i to the Prob macro and recompile the macro and run the code.&lt;/P&gt;
&lt;P&gt;See the difference?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 18:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710248#M218607</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-08T18:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710372#M218662</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

%let food= SUV Sedan Sports ;

proc sql;
create table want as
 select * from sashelp.cars
  where findw(symget('food'),strip(type));
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 09 Jan 2021 13:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710372#M218662</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-09T13:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710566#M218757</link>
      <description>&lt;P&gt;Ah that works nicely.&amp;nbsp; Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 15:07:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/710566#M218757</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-01-11T15:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/711136#M219002</link>
      <description>&lt;P&gt;Was shown this way to accomplish this as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given the TestTable from my original post.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select '"'||strip(C)||'"' into :foods
		separated by ' '
	from TestTable;
quit;

%PUT Foods=&amp;amp;Foods.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This also works with the distinct predicate. such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select distinct '"'||Strip(type)||'"' into :CarTypes
		separated by ' '
	from sashelp.cars;
quit;

%PUT CarTypes=&amp;amp;CarTypes.;&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, 13 Jan 2021 14:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/711136#M219002</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-01-13T14:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a where statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/711140#M219004</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Note that the IN operator does not need commas.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But it accepts them, while the WHEN statement &lt;EM&gt;requires&lt;/EM&gt; them. So I always use commas, as I've found that I often convert IF/THEN/ELSE statements with an IN operator to SELECT blocks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sure but the commas make it difficult to pass the strings as arguments to macro functions or macro calls.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 14:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/711140#M219004</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-13T14:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use a list of items in a macrovariable in  a whare statement and in operator?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/711144#M219006</link>
      <description>&lt;P&gt;Two problems with&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'"'||strip(C)||'"'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;First is that using STRIP() instead of TRM() will remove any leading spaces from the values of C.&amp;nbsp; So that the quoted strings will now no longer match the value that is in the dataset.&lt;/P&gt;
&lt;P&gt;Second is when the value of C contains quote characters.&amp;nbsp; You need to double any quote characters to make a valid string literal.&lt;/P&gt;
&lt;P&gt;Better to use the TRIM() and QUOTE() functions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;quote(trim(C))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jan 2021 15:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-use-a-list-of-items-in-a-macrovariable-in-a-whare/m-p/711144#M219006</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-13T15:01:29Z</dc:date>
    </item>
  </channel>
</rss>

