<?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: How can I reference a table for a WHERE IN statement? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-reference-a-table-for-a-WHERE-IN-statement/m-p/683111#M206866</link>
    <description>Thanks.  It's been months since I've touched SAS and wasn't sure how the merge would work.  I didn't know if it would only give me 4 rows.  Looks like it works as long as my material numbers are unique.</description>
    <pubDate>Thu, 10 Sep 2020 22:38:40 GMT</pubDate>
    <dc:creator>BarryP</dc:creator>
    <dc:date>2020-09-10T22:38:40Z</dc:date>
    <item>
      <title>How can I reference a table for a WHERE IN statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-reference-a-table-for-a-WHERE-IN-statement/m-p/683106#M206861</link>
      <description>&lt;P&gt;This is what I want to accomplish:&lt;BR /&gt;&lt;BR /&gt;Data Table_I_Want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;set work.Source_Table;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;where MATERIAL_NUMBER in (&lt;BR /&gt;&lt;BR /&gt;'1001'&lt;BR /&gt;'1002'&lt;BR /&gt;'1005'&lt;BR /&gt;'1011'&lt;BR /&gt;);&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I'd like to be able to accomplish this by referencing a table with a list of material numbers.&amp;nbsp; It does not need to be a WHERE IN statement.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 22:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-reference-a-table-for-a-WHERE-IN-statement/m-p/683106#M206861</guid>
      <dc:creator>BarryP</dc:creator>
      <dc:date>2020-09-10T22:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reference a table for a WHERE IN statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-reference-a-table-for-a-WHERE-IN-statement/m-p/683108#M206863</link>
      <description>&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;Data Table_I_Want;
     merge work.Source_Table
           reference_table (in=inreference)
     ;

     by MATERIAL_NUMBER;
     if inreference;
run;&lt;/PRE&gt;
&lt;P&gt;The (in=inreference) creates a SAS temporary variable that is true/false or 1/0 when the current record has a contribution from that data set. This would require both data sets to be sorted by Material_number. Hopefully your reference_table, or what ever the name might be, does not have repeats of any Material_number values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 22:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-reference-a-table-for-a-WHERE-IN-statement/m-p/683108#M206863</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-10T22:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reference a table for a WHERE IN statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-reference-a-table-for-a-WHERE-IN-statement/m-p/683110#M206865</link>
      <description>&lt;P&gt;Ok, I think I have it.&amp;nbsp; This is how I'm doing it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data Material_Num_Table;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;input @1 MATERIAL_NUMBER $54.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;datalines;&lt;/P&gt;
&lt;P&gt;1001&lt;/P&gt;
&lt;P&gt;1002&lt;BR /&gt;1005&lt;/P&gt;
&lt;P&gt;1011&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Table_I_Want;&lt;BR /&gt;&lt;BR /&gt;merge Material_Num_Table(in=InMat) Source_Table(;&lt;BR /&gt;by MATERIAL_NUMBER ;&lt;BR /&gt;if InMat;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 22:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-reference-a-table-for-a-WHERE-IN-statement/m-p/683110#M206865</guid>
      <dc:creator>BarryP</dc:creator>
      <dc:date>2020-09-10T22:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I reference a table for a WHERE IN statement?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-reference-a-table-for-a-WHERE-IN-statement/m-p/683111#M206866</link>
      <description>Thanks.  It's been months since I've touched SAS and wasn't sure how the merge would work.  I didn't know if it would only give me 4 rows.  Looks like it works as long as my material numbers are unique.</description>
      <pubDate>Thu, 10 Sep 2020 22:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-reference-a-table-for-a-WHERE-IN-statement/m-p/683111#M206866</guid>
      <dc:creator>BarryP</dc:creator>
      <dc:date>2020-09-10T22:38:40Z</dc:date>
    </item>
  </channel>
</rss>

