<?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: Check the longest substring two strings have in common in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510452#M1958</link>
    <description>&lt;P&gt;When you say "substring" do you mean any characters, or words only?&amp;nbsp; For example, is there any match at all here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Business || MyBusiness Ltd.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Nov 2018 15:42:07 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-11-05T15:42:07Z</dc:date>
    <item>
      <title>Check the longest substring two strings have in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510444#M1956</link>
      <description>&lt;P&gt;Data example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Company ABCDE || ABCDE is the&amp;nbsp;organisation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. MyBusiness || MyBusiness Ltd.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Governmental agency FGHIJ || G. A. FGHIJ etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. Made Up Company Name || "Made Up" Name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From these four records, I wish to&amp;nbsp;get an indication of what is the longest substring that could be matched between the two values. This can be in numbers (e.g. 5 for the first record, 10 for the second) but preferably also create a new variable with that substring (e. g. ABCDE or MyBusiness) so that I can do a visual check of the match.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 15:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510444#M1956</guid>
      <dc:creator>SarahDew</dc:creator>
      <dc:date>2018-11-05T15:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Check the longest substring two strings have in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510452#M1958</link>
      <description>&lt;P&gt;When you say "substring" do you mean any characters, or words only?&amp;nbsp; For example, is there any match at all here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Business || MyBusiness Ltd.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 15:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510452#M1958</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-11-05T15:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Check the longest substring two strings have in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510458#M1961</link>
      <description>I mean any characters. In your example "Business" would be the matched substring.</description>
      <pubDate>Mon, 05 Nov 2018 15:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510458#M1961</guid>
      <dc:creator>SarahDew</dc:creator>
      <dc:date>2018-11-05T15:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Check the longest substring two strings have in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510606#M1990</link>
      <description>&lt;P&gt;That's very expensive to calculate. If your goal is to match strings, have you considered using the spelling distance functions COMPGED, COMPLEV&amp;nbsp;or SPEDIS?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 21:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510606#M1990</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-11-05T21:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Check the longest substring two strings have in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510700#M2012</link>
      <description>&lt;P&gt;Yes, I have already determined many matches using the COMPGED and FIND functions. However, for my third example record none of these methods work since&amp;nbsp;many manipulations are needed to get from one string to the other, and none of the two values are exactly found in the other.&amp;nbsp;But it is not too bad that it would be expensive since I have already greatly reduced the set of non-matched records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe a less expensive alternative would be to do a&amp;nbsp;loop where every possible substring of 4&amp;nbsp;characters of&amp;nbsp;var1 is looked up in var2 trough the FIND function and vice versa? Any ideas on how to write this sort of code?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 08:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510700#M2012</guid>
      <dc:creator>SarahDew</dc:creator>
      <dc:date>2018-11-06T08:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Check the longest substring two strings have in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510743#M2021</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $80.;
cards;
Company ABCDE || ABCDE is the organisation
MyBusiness || MyBusiness Ltd.
Governmental agency FGHIJ || G. A. FGHIJ etc.
Made Up Company Name || "Made Up" Name
;
run;
data want;
 set have;
 x1=scan(x,1,'|'); x2=scan(x,-1,'|');
 len=length(x1);
 do length=len to 1 by -1;
  do start=1 to len-length+1; 
   substr=substr(x1,start,length);
   if find(x2,strip(substr)) and substr ne: ' ' then do;yes=1;leave;end;
  end;
  if yes then leave;
 end;
drop len start yes x1 x2;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Nov 2018 13:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/510743#M2021</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-06T13:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: Check the longest substring two strings have in common</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/511004#M2076</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;! Works like a charm.</description>
      <pubDate>Wed, 07 Nov 2018 12:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Check-the-longest-substring-two-strings-have-in-common/m-p/511004#M2076</guid>
      <dc:creator>SarahDew</dc:creator>
      <dc:date>2018-11-07T12:13:09Z</dc:date>
    </item>
  </channel>
</rss>

