<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql/m-p/484183#M125668</link>
    <description>&lt;P&gt;That is one of the nicest features of SAS code, especially if you need to create macros that take in lists of values as parameters.&lt;/P&gt;
&lt;P&gt;Commas are a pain to pass into macro calls because they are used to separate parameters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro subset(in,out,var,list);
data &amp;amp;out;
 set &amp;amp;in;
 where &amp;amp;var in (&amp;amp;list);
run;
%mend subset;

proc sql noprint;
  select quote(trim(name)) into :mylist separated by ' '
    from sashelp.class
    where sex='F'
  ;
quit;

%subset(in=sashelp.class,out=females,var=name,list=&amp;amp;mylist);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 05 Aug 2018 17:19:19 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-08-05T17:19:19Z</dc:date>
    <item>
      <title>IN operator in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql/m-p/484116#M125632</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;In proc sql i want to use in operator.&lt;/P&gt;&lt;P&gt;What is the correct way?&lt;/P&gt;&lt;P&gt;If there are some items ,should I use comma between them or also a space can work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I run this example and both method worked&amp;nbsp;&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;

PROC SQL;
	create table outcome as
	select *	   
	from tbl
	where branch in (100, 200, 300, 400, 500)
;
QUIT;

PROC SQL;
	create table outcome as
	select *	   
	from tbl
	where branch in (100  200  300  400  500)
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Aug 2018 08:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql/m-p/484116#M125632</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-05T08:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: IN operator in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql/m-p/484122#M125638</link>
      <description>&lt;P&gt;Both methods are equal. I personally prefer commas in "in"-lists because I rarely use SQL and commas are needed in the when() conditions of select() blocks in data steps, where the in-lists often end up.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 08:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql/m-p/484122#M125638</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-05T08:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: IN operator in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql/m-p/484126#M125642</link>
      <description>&lt;P&gt;They generate identical results, but IMO it is bad programming practice to omit the commas.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 10:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql/m-p/484126#M125642</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-08-05T10:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: IN operator in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql/m-p/484183#M125668</link>
      <description>&lt;P&gt;That is one of the nicest features of SAS code, especially if you need to create macros that take in lists of values as parameters.&lt;/P&gt;
&lt;P&gt;Commas are a pain to pass into macro calls because they are used to separate parameters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro subset(in,out,var,list);
data &amp;amp;out;
 set &amp;amp;in;
 where &amp;amp;var in (&amp;amp;list);
run;
%mend subset;

proc sql noprint;
  select quote(trim(name)) into :mylist separated by ' '
    from sashelp.class
    where sex='F'
  ;
quit;

%subset(in=sashelp.class,out=females,var=name,list=&amp;amp;mylist);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Aug 2018 17:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-in-proc-sql/m-p/484183#M125668</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-05T17:19:19Z</dc:date>
    </item>
  </channel>
</rss>

