<?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 How Can I Do a Fuzzy Character Merge using Hash Objects in SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Do-a-Fuzzy-Character-Merge-using-Hash-Objects-in-SAS/m-p/765707#M242545</link>
    <description>&lt;P&gt;I'm testing out how to use hash objects in SAS 9.4 M6 to do fuzzy joins since PROC SQL just runs for hours on my larger dataset. I created some sample datasets (below) and what I want is for the merge to pull in exact matches on the "name" fields AND any matches that have a COMPLEV score less than 10. Right now, this code still only pulls in the exact matches.&amp;nbsp;I'm very new to hash objects so I'm sure it's a simple fix but I've tried am in need of help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data A;
infile datalines missover;
length nameA $50;
input nameA $ ;
datalines;
MICKEYMOUSE2000-01-02
DAFDUCK1990-09-23
GOOFYMAN1993-05-11
;
run;

*second dataset with one exact match and two that differ slightly from those in dataset A;
data B;
infile datalines missover;
length nameB $50;
input nameB $ VDAY :ddmmyy10.;
format VDAY ddmmyy10.;
datalines;
MICKEYMOUSE2000-01-01 07/08/2021
DAFFYDUCK1990-09-23 05/11/2021
GOOFYMAN1993-05-11 08/11/2021
;
run;

*only pulling in exact matches, want it to pull in other fuzzy matches;

data simplemerge ;

if 0 then set work.B ; *load var properties into hash table;

if _n_ = 1 then do;
    dcl hash B (dataset: 'work.B'); *declare the name B for hash using B dataset;
    B.definekey('nameB');*identify var in B to use as key;
    B.definedata('nameB','vday');*identify columns of data to bring in from B dataset;
    B.definedone();*complete hash table definition;
end;

set work.A; *bring in A data;

if B.Find(KEY: nameA) ne 0 then do;
        if complev(nameA, nameB) &amp;lt; 10 then do;
            B.ref(key : nameB,data : nameB, data : vday);
        end;
end;

RUN;&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Sep 2021 19:25:41 GMT</pubDate>
    <dc:creator>cgates</dc:creator>
    <dc:date>2021-09-02T19:25:41Z</dc:date>
    <item>
      <title>How Can I Do a Fuzzy Character Merge using Hash Objects in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Do-a-Fuzzy-Character-Merge-using-Hash-Objects-in-SAS/m-p/765707#M242545</link>
      <description>&lt;P&gt;I'm testing out how to use hash objects in SAS 9.4 M6 to do fuzzy joins since PROC SQL just runs for hours on my larger dataset. I created some sample datasets (below) and what I want is for the merge to pull in exact matches on the "name" fields AND any matches that have a COMPLEV score less than 10. Right now, this code still only pulls in the exact matches.&amp;nbsp;I'm very new to hash objects so I'm sure it's a simple fix but I've tried am in need of help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data A;
infile datalines missover;
length nameA $50;
input nameA $ ;
datalines;
MICKEYMOUSE2000-01-02
DAFDUCK1990-09-23
GOOFYMAN1993-05-11
;
run;

*second dataset with one exact match and two that differ slightly from those in dataset A;
data B;
infile datalines missover;
length nameB $50;
input nameB $ VDAY :ddmmyy10.;
format VDAY ddmmyy10.;
datalines;
MICKEYMOUSE2000-01-01 07/08/2021
DAFFYDUCK1990-09-23 05/11/2021
GOOFYMAN1993-05-11 08/11/2021
;
run;

*only pulling in exact matches, want it to pull in other fuzzy matches;

data simplemerge ;

if 0 then set work.B ; *load var properties into hash table;

if _n_ = 1 then do;
    dcl hash B (dataset: 'work.B'); *declare the name B for hash using B dataset;
    B.definekey('nameB');*identify var in B to use as key;
    B.definedata('nameB','vday');*identify columns of data to bring in from B dataset;
    B.definedone();*complete hash table definition;
end;

set work.A; *bring in A data;

if B.Find(KEY: nameA) ne 0 then do;
        if complev(nameA, nameB) &amp;lt; 10 then do;
            B.ref(key : nameB,data : nameB, data : vday);
        end;
end;

RUN;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Sep 2021 19:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Do-a-Fuzzy-Character-Merge-using-Hash-Objects-in-SAS/m-p/765707#M242545</guid>
      <dc:creator>cgates</dc:creator>
      <dc:date>2021-09-02T19:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: How Can I Do a Fuzzy Character Merge using Hash Objects in SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Do-a-Fuzzy-Character-Merge-using-Hash-Objects-in-SAS/m-p/765774#M242579</link>
      <description>&lt;P&gt;Hash tables only perform equijoins.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To speed up your fuzzy SQL match, split it. For example:&lt;/P&gt;
&lt;P&gt;1- Match on same value&lt;/P&gt;
&lt;P&gt;2- Take the unmatched records and match on same uppercase values&lt;/P&gt;
&lt;P&gt;3- Take the unmatched records and match on same first letter and same compbl() value&lt;/P&gt;
&lt;P&gt;4- Take the unmatched records and match on same first letter and same length and complev()&lt;/P&gt;
&lt;P&gt;5- Take the unmatched records and match on same first letter and complev()&lt;/P&gt;
&lt;P&gt;6- Take the unmatched records and match on complev()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adapt the steps to your data. The goal is to &lt;U&gt;increase match complexity as you lower volume&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;The code above is just an example: I'd hope that you have standardised things such case, punctuation or spacing.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 00:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-Can-I-Do-a-Fuzzy-Character-Merge-using-Hash-Objects-in-SAS/m-p/765774#M242579</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-09-03T00:18:16Z</dc:date>
    </item>
  </channel>
</rss>

