<?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: Identifying non-exact duplicates in the same dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-non-exact-duplicates-in-the-same-dataset/m-p/615847#M180179</link>
    <description>It doesn't matter if it's the same column or not, you can self join or do a self look up.</description>
    <pubDate>Wed, 08 Jan 2020 03:38:06 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-01-08T03:38:06Z</dc:date>
    <item>
      <title>Identifying non-exact duplicates in the same dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-non-exact-duplicates-in-the-same-dataset/m-p/615838#M180176</link>
      <description>&lt;P&gt;I have some data with first name, last name, and address. I would like to flag all the observations that have the same first and last name, and also ~similar~ address. i.e. (p.s. I already used upcase and compress to fix case and formatting, just need to worry about the actual string characters)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First&amp;nbsp; &amp;nbsp; Last&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Address&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag&lt;/P&gt;&lt;P&gt;BOB&amp;nbsp; &amp;nbsp; SMITH&amp;nbsp; 100 SAS RD&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;BOB&amp;nbsp; &amp;nbsp; SMITH&amp;nbsp; 100 N SAS RD&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;BOB&amp;nbsp; &amp;nbsp; JONES&amp;nbsp; 1000 R RD&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know there are a lot of functions for fuzzy matching but that seems to only be between 2 datasets, not within the same column. Any advice on how to tackle this?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 01:29:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-non-exact-duplicates-in-the-same-dataset/m-p/615838#M180176</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2020-01-08T01:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying non-exact duplicates in the same dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-non-exact-duplicates-in-the-same-dataset/m-p/615841#M180178</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/140721"&gt;@Melk&lt;/a&gt;&amp;nbsp; How about experimenting SPEDIS with a penalty set at 15?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input First $   Last  $     Address   &amp;amp; $15.;              
cards;
BOB    SMITH  100 SAS RD            1
BOB    SMITH  100 N SAS RD        1
BOB    JONES  1000 R RD              0
;

data want ;
  set have;
  by first last notsorted;
  length _addr $15;
  retain flag _addr; 
  if  first.last or  spedis(_addr,address)&amp;lt;15 then do;
   _addr=address;
   Flag=1;
  end;
  else 	 if  spedis(_addr,address)&amp;gt;=15 then Flag=0;
  drop _addr;
run;




 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2020 02:10:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-non-exact-duplicates-in-the-same-dataset/m-p/615841#M180178</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-08T02:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying non-exact duplicates in the same dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-non-exact-duplicates-in-the-same-dataset/m-p/615847#M180179</link>
      <description>It doesn't matter if it's the same column or not, you can self join or do a self look up.</description>
      <pubDate>Wed, 08 Jan 2020 03:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-non-exact-duplicates-in-the-same-dataset/m-p/615847#M180179</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-08T03:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying non-exact duplicates in the same dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-non-exact-duplicates-in-the-same-dataset/m-p/615854#M180181</link>
      <description>&lt;P&gt;Inspired by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; , here is a solution using complev&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input First $ Last $ Address &amp;amp;:$15.;              
cards;
BOB    SMITH  100 SAS RD     
BOB    SMITH  100 N SAS RD   
BOB    JONES  1000 R RD      
;

/* Sort so that the longest address is kept as the *true* address */
proc sql;
create table temp as 
select * 
from have
order by last, first, length(address) desc, address;
quit;
 
/* Use the Levenshtein distance, with a cutoff, to detect *real*
   changes in address spellings */    
data want ;
set temp; by last first;
if first.first then do;
	addr = address;
	id + 1;
	end;
else if complev(addr, address, 5) &amp;gt;= 5 then do;
	addr = address;
	id + 1;
	end;
retain addr;
run;

proc print data=want; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs. 	First 	Last 	Address 	addr 	id
1 	BOB 	JONES 	1000 R RD 	1000 R RD 	1
2 	BOB 	SMITH 	100 N SAS RD 	100 N SAS RD 	2
3 	BOB 	SMITH 	100 SAS RD 	100 N SAS RD 	2&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2020 05:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-non-exact-duplicates-in-the-same-dataset/m-p/615854#M180181</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-01-08T05:40:59Z</dc:date>
    </item>
  </channel>
</rss>

