<?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: Efficient hash Look-up in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546727#M8256</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data history;
input ID $	(Post1	Post2	Post3	Post4	Post5	Postal1	Postal2	Postal3	Postal4	Postal5) ($);
cards;
1	P2e3	P2e4	P2e5	P2e6	P2e7	P2e8	P2e9	P2e0	P2e4	P2e8
2	P2e7	P2e8	P2e4	P2e4	P2f6	P2e4	P2e8	P2e8	P2e8	P2f1
;
data invalid;
input (id	postal	Sex	dob	Address1	phone) ($);
cards;
1	P2e6	m	9/6/2004	f	123456
2	P2e9	m	9/6/2005	g	654321
3	P2e8	f	9/6/2006	h	789012
;
data want;
merge invalid history;
by id;
array t(*) Post1--Postal5;
length match $10;
if postal in t then match='Match';
else Match='No Match';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Note: ID3 is missing in history table&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Mar 2019 21:33:20 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-03-27T21:33:20Z</dc:date>
    <item>
      <title>Efficient hash Look-up</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546715#M8250</link>
      <description>&lt;P&gt;I am validating some datasets and I wish to look up postal codes in the postal_history dataset. The postal history dataset consists of postal codes for each observation for 10 years. I am trying to see if I can validate by matching postal codes. There are millions of records in the postal_history dataset so I do not want to do a join on&lt;/P&gt;&lt;P&gt;(Postal eq post1 or postal eq post2 or postal eq post3... ) for example. Is there a more efficient way to do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t;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;match&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have =&amp;gt; postal_history and invalid tables&lt;/P&gt;&lt;P&gt;want=&amp;gt;want;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 21:28:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546715#M8250</guid>
      <dc:creator>OLUGBOJI</dc:creator>
      <dc:date>2019-03-27T21:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient hash Look-up</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546718#M8251</link>
      <description>&lt;P&gt;Not clear with the WANT there. Can you clarify your WANT output and the HAVEs plz?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 21:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546718#M8251</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-27T21:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient hash Look-up</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546723#M8253</link>
      <description>&lt;P&gt;Sorry, not clear what you want. And please post data in usable form.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 21:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546723#M8253</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-27T21:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient hash Look-up</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546725#M8255</link>
      <description>&lt;P&gt;untested code, assuming that both datasets are sorted by id and id is unique in both datasets:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge invalid(in=needsProcessing) postal_history;
  by id;

  length match $ 7;

  if needsProcessing;
  
  if findw(catx(' ', Post1, Post2, ...), Postal) then match ='match';
  else match = 'unmatch';

  drop Post1 Post 2 ....;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 21:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546725#M8255</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-03-27T21:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient hash Look-up</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546727#M8256</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data history;
input ID $	(Post1	Post2	Post3	Post4	Post5	Postal1	Postal2	Postal3	Postal4	Postal5) ($);
cards;
1	P2e3	P2e4	P2e5	P2e6	P2e7	P2e8	P2e9	P2e0	P2e4	P2e8
2	P2e7	P2e8	P2e4	P2e4	P2f6	P2e4	P2e8	P2e8	P2e8	P2f1
;
data invalid;
input (id	postal	Sex	dob	Address1	phone) ($);
cards;
1	P2e6	m	9/6/2004	f	123456
2	P2e9	m	9/6/2005	g	654321
3	P2e8	f	9/6/2006	h	789012
;
data want;
merge invalid history;
by id;
array t(*) Post1--Postal5;
length match $10;
if postal in t then match='Match';
else Match='No Match';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Note: ID3 is missing in history table&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 21:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546727#M8256</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-27T21:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient hash Look-up</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546728#M8257</link>
      <description>Thanks. id is unique. Data was not sorted initially and using Hash object would not need sorting.</description>
      <pubDate>Wed, 27 Mar 2019 21:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546728#M8257</guid>
      <dc:creator>OLUGBOJI</dc:creator>
      <dc:date>2019-03-27T21:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient hash Look-up</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546732#M8259</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data history;
input ID $	(Post1	Post2	Post3	Post4	Post5	Postal1	Postal2	Postal3	Postal4	Postal5) ($);
cards;
1	P2e3	P2e4	P2e5	P2e6	P2e7	P2e8	P2e9	P2e0	P2e4	P2e8
2	P2e7	P2e8	P2e4	P2e4	P2f6	P2e4	P2e8	P2e8	P2e8	P2f1
;
data invalid;
input (id	postal	Sex	dob	Address1	phone) ($);
cards;
1	P2e6	m	9/6/2004	f	123456
2	P2e9	m	9/6/2005	g	654321
3	P2e8	f	9/6/2006	h	789012
;
data want;
if _n_=1 then do;
if 0 then set invalid;
dcl hash H () ;
	h.definekey  ("id","post") ;
   h.definedone () ;
   length match $10 post $8;
   call missing(post);
   do until(lr);
   set history end=lr;
   array t(*) Post1--Postal5;
   do i= 1 to dim(t);
   post=t(i);
   rc=h.add();
   end;
   end;
end;
set invalid;
if h.check(key:id,key:postal)=0 then match='Match';
else  Match='No Match';
drop Post1--Postal5 post i rc;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223111"&gt;@OLUGBOJI&lt;/a&gt;&amp;nbsp; &amp;nbsp;Sounds like you want that in hash&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 21:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546732#M8259</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-27T21:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Efficient hash Look-up</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546754#M8263</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223111"&gt;@OLUGBOJI&lt;/a&gt;&amp;nbsp; &amp;nbsp;This is better i think&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data history;
input ID $	(Post1	Post2	Post3	Post4	Post5	Postal1	Postal2	Postal3	Postal4	Postal5) ($);
cards;
1	P2e3	P2e4	P2e5	P2e6	P2e7	P2e8	P2e9	P2e0	P2e4	P2e8
2	P2e7	P2e8	P2e4	P2e4	P2f6	P2e4	P2e8	P2e8	P2e8	P2f1
;
data invalid;
input (id	postal	Sex	dob	Address1	phone) ($);
cards;
1	P2e6	m	9/6/2004	f	123456
2	P2e9	m	9/6/2005	g	654321
3	P2e8	f	9/6/2006	h	789012
;

data want;
if _n_=1 then do;
if 0 then set invalid;
dcl hash H (dataset:'invalid') ;
	h.definekey  ("id") ;
   h.definedata (all:'y') ;
   h.definedone();
   end;
set history;
array t(*) Post1--Postal5;
length match $10;
rc=h.find();
if postal in t then match='Match';
else Match='No Match';
drop rc Post1--Postal5;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2019 22:56:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Efficient-hash-Look-up/m-p/546754#M8263</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-27T22:56:59Z</dc:date>
    </item>
  </channel>
</rss>

