<?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: Create a 'look up' list for a where statement in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-look-up-list-for-a-where-statement/m-p/398995#M25645</link>
    <description>&lt;P&gt;Put your list into a pemanent reference&amp;nbsp;table, then use proc SQL to build a string from that list and load it into a macro variable. You can then use the macro variable in your where clause like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data list;
	length name $8;
	infile datalines;
	input name;
	datalines;
John
Judy
Mary
;
run;

proc sql;
	select quote(trim(name)) into :name_list
	separated by " "
	from list;
quit;


proc sort data=sashelp.class out=class;
	by name;
	where name in (&amp;amp;name_list);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You only then need to update the table when and if your codes change.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2017 01:09:15 GMT</pubDate>
    <dc:creator>ChrisBrooks</dc:creator>
    <dc:date>2017-09-27T01:09:15Z</dc:date>
    <item>
      <title>Create a 'look up' list for a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-look-up-list-for-a-where-statement/m-p/398992#M25643</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At times I have large lists that I need to included in a Where statement (up too 387).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way I can create a list and reference that in the Where statement instead of having the individual code included in the statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the example below remove all the AAA_ and reference a list that contains all of these.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Sort data=Data.preagent out=Work.TrainingOverlay
	(Keep= week_end_dt CLUSTER Queue_CD Calls_Entered_cnt CALLS_ANSWERED_CNT);
	BY week_end_dt CLUSTER Queue_CD;
	Where week_end_dt &amp;gt;= '01Jul2016.'d
		and Queue_CD in (
						'AAA_ABR' 
'AAA_ABS' 
'AAA_ABS' 
'AAA_ACD' 
'AAA_ACE' 
'AAA_ACR' 
'AAA_ACY' 
'AAA_ADV' 
'AAA_AEC' 
'AAA_AEI' 
'AAA_AES' 
'AAA_AIN' 
'AAA_AIP' 
'AAA_ALD' 
'AAA_ALE' 
'AAA_ALN' 
'AAA_ALR' 
'AAA_ALY' 
'AAA_APR' 
'AAA_ARA' 
'AAA_ASR' 
'AAA_BOS' 
'AAA_BRA' 
'AAA_BVL' 
'AAA_BVL' 
'AAA_CAN' 
'AAA_CCB' 
'AAA_CCP' 
'AAA_CDT' 
'AAA_CHD' 
'AAA_CHK' 
'AAA_CHS' 
'AAA_CHY' 
'AAA_CLH' 
'AAA_CMC' );
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dean&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 00:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-look-up-list-for-a-where-statement/m-p/398992#M25643</guid>
      <dc:creator>DME790</dc:creator>
      <dc:date>2017-09-27T00:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create a 'look up' list for a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-look-up-list-for-a-where-statement/m-p/398995#M25645</link>
      <description>&lt;P&gt;Put your list into a pemanent reference&amp;nbsp;table, then use proc SQL to build a string from that list and load it into a macro variable. You can then use the macro variable in your where clause like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data list;
	length name $8;
	infile datalines;
	input name;
	datalines;
John
Judy
Mary
;
run;

proc sql;
	select quote(trim(name)) into :name_list
	separated by " "
	from list;
quit;


proc sort data=sashelp.class out=class;
	by name;
	where name in (&amp;amp;name_list);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You only then need to update the table when and if your codes change.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 01:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-look-up-list-for-a-where-statement/m-p/398995#M25645</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-09-27T01:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create a 'look up' list for a where statement</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-look-up-list-for-a-where-statement/m-p/399326#M25666</link>
      <description>&lt;P&gt;An extension on &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32246"&gt;@ChrisBrooks&lt;/a&gt;&amp;nbsp;if you have subsets of the values you use frequently would be to add other variables to indicate membership. Then select using that indicator:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data lookup;
   input Code $ Region type ;
datalines;
AAA_ABR 1 0
AAA_ABS 1 1
AAA_ABS 0 1
AAA_ACD 1 1
AAA_ACE 1 0
;
run;
proc sql;
	select quote(trim(code)) into :code_list
	separated by " "
	from lookup
   where Region=1;
quit;&lt;/PRE&gt;
&lt;P&gt;If I used this very frequently and the list was relatively static I might consider a series of formats similar to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $FirstKeep
'AAA_ABR', 
'AAA_ABS', 
'AAA_ABS', 
'AAA_ACD', 
'AAA_ACE', 
'AAA_ACR', 
'AAA_ACY', 
'AAA_ADV', 
'AAA_AEC', 
'AAA_AEI', 
'AAA_AES', 
'AAA_AIN', 
'AAA_AIP', 
'AAA_ALD', 
'AAA_ALE', 
'AAA_ALN', 
'AAA_ALR', 
'AAA_ALY', 
'AAA_APR', 
'AAA_ARA', 
'AAA_ASR', 
'AAA_BOS', 
'AAA_BRA', 
'AAA_BVL', 
'AAA_BVL', 
'AAA_CAN', 
'AAA_CCB', 
'AAA_CCP', 
'AAA_CDT', 
'AAA_CHD', 
'AAA_CHK', 
'AAA_CHS', 
'AAA_CHY', 
'AAA_CLH', 
'AAA_CMC', 
   = 'Keep'
other ='Drop'
;
run;&lt;/PRE&gt;
&lt;P&gt;and then use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Where week_end_dt &amp;gt;= '01Jul2016.'d
		and put(Queue_CD,$FirstKeep.)='Keep'&lt;/PRE&gt;
&lt;P&gt;If the lists you want exist in data sets then they can likely be modified to create formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2017 20:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-look-up-list-for-a-where-statement/m-p/399326#M25666</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-27T20:04:31Z</dc:date>
    </item>
  </channel>
</rss>

