<?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: Filtering using another table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Filtering-using-another-table/m-p/593733#M170455</link>
    <description>&lt;P&gt;Hi and welcome to the SAS Communtiy &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if this is applicable to your actual problem. Otherwise, don't hesitate to ask&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
input id var1;
datalines;
1 10
1 20
2 30
2 40
3 50
3 60
;

data table2;
input id var2;
datalines;
1 10
1 20
3 50
3 60
;

data want;
    if _N_=1 then do;
        declare hash h(dataset:'table2');
        h.definekey('id');
        h.definedone();
    end;

    set table1;

    if h.check()=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 03 Oct 2019 14:19:01 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-10-03T14:19:01Z</dc:date>
    <item>
      <title>Filtering using another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-using-another-table/m-p/593732#M170454</link>
      <description>&lt;P&gt;I have 2 SAS tables, both of them have similar IDs. I want to filter table 1 to have only the IDs in table 2.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 14:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-using-another-table/m-p/593732#M170454</guid>
      <dc:creator>alabchaa</dc:creator>
      <dc:date>2019-10-03T14:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering using another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-using-another-table/m-p/593733#M170455</link>
      <description>&lt;P&gt;Hi and welcome to the SAS Communtiy &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if this is applicable to your actual problem. Otherwise, don't hesitate to ask&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
input id var1;
datalines;
1 10
1 20
2 30
2 40
3 50
3 60
;

data table2;
input id var2;
datalines;
1 10
1 20
3 50
3 60
;

data want;
    if _N_=1 then do;
        declare hash h(dataset:'table2');
        h.definekey('id');
        h.definedone();
    end;

    set table1;

    if h.check()=0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Oct 2019 14:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-using-another-table/m-p/593733#M170455</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-03T14:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering using another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-using-another-table/m-p/593742#M170462</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If ID are integers you could try direct addressing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For range up to 1mln it will required ~8MB of RAM, for 10mln&amp;nbsp;it will required ~8oMB,&amp;nbsp;for 100mln&amp;nbsp;it will required ~8ooMB, and so on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
input id var1;
datalines;
1 10
1 20
2 30
2 40
3 50
3 60
;
run;

data table2;
input id var2;
datalines;
1 10
1 20
3 50
3 60
;
run;

options fullstimer msglevel=i;
%let size = 1000000;
data want;
    array t[&amp;amp;size.] _temporary_; 

    do until(eof1);
      set table2(keep = id) end=eof1;
      t[id] = 1;
    end;

    do until(eof2);
      set table1 end=eof2;
      if t[id] = 1 then output;
    end;
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Oct 2019 14:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-using-another-table/m-p/593742#M170462</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-10-03T14:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering using another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-using-another-table/m-p/593746#M170464</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
input id var1;
datalines;
1 10
1 20
2 30
2 40
3 50
3 60
;
run;

data table2;
input id var2;
datalines;
1 10
1 20
3 50
3 60
;
run;

proc sql;
create table want as
select *
from table1
where id in (select distinct id from table2);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Oct 2019 14:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-using-another-table/m-p/593746#M170464</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-10-03T14:38:08Z</dc:date>
    </item>
  </channel>
</rss>

