<?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 fuzzy matches within a single variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-fuzzy-matches-within-a-single-variable/m-p/876490#M346274</link>
    <description>&lt;P&gt;"I'm trying to identify the files that occur in the directory more than once. "&amp;nbsp; Easy: none.&lt;/P&gt;
&lt;P&gt;SIMILARLY named is valid question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The functions COMPGED and similar would be a place to start.&lt;/P&gt;
&lt;P&gt;Here is a small example generating three different scores. Lower score are "more similar" within one of the comparisons.&lt;/P&gt;
&lt;PRE&gt;data have;
   input str $;
datalines;
abc
abc1
abc_1
abc*
pdq
pdc1
;

proc sql;
   create table example as
   select a.str as stringa,b.str as stringb
         ,compged(a.str,b.str) as compgedscore         
         ,complev(a.str,b.str) as complevscore
         ,spedis(a.str,b.str) as spedisscore
   from have as a, have as b
   where a.str ne b.str
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Look at some of your values and you could set a threshold for a specific scoring method to select likely "similar" names.&lt;/P&gt;
&lt;P&gt;Read the documentation for the functions. I'm not going to repeat paragraphs of details.&lt;/P&gt;
&lt;P&gt;Not the you can create custom scoring rules for COMPGED using the CALL COMPCOST routine but likely not worth the effort unless you have hundreds of similarity patterns to look for.&lt;/P&gt;</description>
    <pubDate>Thu, 18 May 2023 15:19:50 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-05-18T15:19:50Z</dc:date>
    <item>
      <title>Identifying fuzzy matches within a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-fuzzy-matches-within-a-single-variable/m-p/876482#M346269</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset which is a directory listing produced using a pipe statement. It has folder and file names.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm trying to get at specifically is that there are some cases where the file name is close, but not identical.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Think:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;clinic_file_clin1.csv&lt;/P&gt;
&lt;P&gt;clinic_file_clin1_c.csv&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So clinic_file_ is the beginning of all the file names, clin# is the clinic name (should only be one per directory). The difference will be something at the end like _c, _copy, _fixed, or something like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to identify the files that occur in the directory more than once.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the best approach for this? I assume fuzzy matching of some kind, but from poking around it seems like that is usually across two columns/while matching.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 15:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-fuzzy-matches-within-a-single-variable/m-p/876482#M346269</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2023-05-18T15:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying fuzzy matches within a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-fuzzy-matches-within-a-single-variable/m-p/876486#M346271</link>
      <description>You can self join a dataset, if you know it will always be the same with a suffix, you can use like.</description>
      <pubDate>Thu, 18 May 2023 15:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-fuzzy-matches-within-a-single-variable/m-p/876486#M346271</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-18T15:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying fuzzy matches within a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-fuzzy-matches-within-a-single-variable/m-p/876490#M346274</link>
      <description>&lt;P&gt;"I'm trying to identify the files that occur in the directory more than once. "&amp;nbsp; Easy: none.&lt;/P&gt;
&lt;P&gt;SIMILARLY named is valid question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The functions COMPGED and similar would be a place to start.&lt;/P&gt;
&lt;P&gt;Here is a small example generating three different scores. Lower score are "more similar" within one of the comparisons.&lt;/P&gt;
&lt;PRE&gt;data have;
   input str $;
datalines;
abc
abc1
abc_1
abc*
pdq
pdc1
;

proc sql;
   create table example as
   select a.str as stringa,b.str as stringb
         ,compged(a.str,b.str) as compgedscore         
         ,complev(a.str,b.str) as complevscore
         ,spedis(a.str,b.str) as spedisscore
   from have as a, have as b
   where a.str ne b.str
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Look at some of your values and you could set a threshold for a specific scoring method to select likely "similar" names.&lt;/P&gt;
&lt;P&gt;Read the documentation for the functions. I'm not going to repeat paragraphs of details.&lt;/P&gt;
&lt;P&gt;Not the you can create custom scoring rules for COMPGED using the CALL COMPCOST routine but likely not worth the effort unless you have hundreds of similarity patterns to look for.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 15:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-fuzzy-matches-within-a-single-variable/m-p/876490#M346274</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-18T15:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying fuzzy matches within a single variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-fuzzy-matches-within-a-single-variable/m-p/876508#M346283</link>
      <description>&lt;P&gt;If this is only at the end, then something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input file_name :$50.;
cards;
clinic_file_clin1.csv
clinic_file_clin1_c.csv
clinic_file_clin2.csv
clinic_file_clin2_fixed.csv
;

proc sql;
create table want as
select t1.file_name, t2.file_name as possible_duplicate
from have as t1
cross join have as t2
where find(scan(t1.file_name, 1, "."), scan(t2.file_name, 1, "."), 'it') &amp;gt;0 and t1.file_name ne t2.file_name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2023 16:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-fuzzy-matches-within-a-single-variable/m-p/876508#M346283</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-18T16:20:35Z</dc:date>
    </item>
  </channel>
</rss>

