<?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: Merging on a Partial/Prefix Key in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360736#M84994</link>
    <description>&lt;P&gt;I used this method on my 12.4 million row master table. After 24 hours I stopped it. It processed about 1/4 of the master table, but does have a match for each row. I'm going to visually inspect the matching to see if it appears to be accurate. Then, I may subset the master table and run the process in pieces, unless anyone has an idea how to make this run more efficiently. I could try indexing both the master table and the lookup table, but I don't know if indexes matter to this matching process. Thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2017 13:53:01 GMT</pubDate>
    <dc:creator>CurtisSmithDCAA</dc:creator>
    <dc:date>2017-05-23T13:53:01Z</dc:date>
    <item>
      <title>Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360046#M84696</link>
      <description>&lt;P&gt;I don't know why I have not encountered this before, but...&lt;/P&gt;&lt;P&gt;I need to merge two SAS data sets, both with the same key variable, but in the lookup&amp;nbsp;data set&amp;nbsp;the key may only contain the first few characters of the key in the&amp;nbsp;master data set. For some rows, the key values in both data sets will exactly match. In other rows, the lookup data set may only be partial, but still exact for as many characters as are in the key value. When the lookup data set has only part of the full key value (essentially, a prefix), it will still be unique: that is, no two rows in the lookup data set will have the same key value. So, the merge would need to be similar to performing a WHERE statement using the LIKE operator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking of pursuing fuzzy matching, but that process seems too impercise for my needs. I don't risk incorrect matching as long as I can match based on the first few characters of the key in the lookup data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on the right direction to take?&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 17:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360046#M84696</guid>
      <dc:creator>CurtisSmithDCAA</dc:creator>
      <dc:date>2017-05-19T17:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360059#M84702</link>
      <description>&lt;P&gt;Can you provide examples of the two data steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 17:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360059#M84702</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-19T17:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360066#M84704</link>
      <description>&lt;P&gt;The two data sets might look something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Master data set:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Contract&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dollars&lt;/P&gt;&lt;P&gt;ABC12345&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1000&lt;/P&gt;&lt;P&gt;BCD98765&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5000&lt;/P&gt;&lt;P&gt;XYZ99999&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lookup data set:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Contract&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Customer&lt;/P&gt;&lt;P&gt;ABC12345&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Army&lt;/P&gt;&lt;P&gt;BCD&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Navy&lt;/P&gt;&lt;P&gt;XYZ99999&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Air Force&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An exact match using contract as the BY variable will merge contracts ABC12345 and XYZ99999, but not contract BCD. but I want to match it with customer "Navy".&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 17:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360066#M84704</guid>
      <dc:creator>CurtisSmithDCAA</dc:creator>
      <dc:date>2017-05-19T17:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360070#M84705</link>
      <description>&lt;P&gt;Here is one way:&lt;/P&gt;
&lt;PRE&gt;data master;
  input Contract $ Dollars;
  cards;
ABC12345        1000
BCD98765        5000
XYZ99999        100
;

data lookup;
  input Contract$ Customer $;
  cards;
ABC12345       Army
BCD                 Navy
XYZ99999       Air Force
;

proc sql noprint;
  create table want as
    SELECT a.*, b.Customer
      FROM master a
       left JOIN lookup b
         ON a.Contract LIKE catt('%', b.Contract, '%') 
  ;
quit;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 17:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360070#M84705</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-19T17:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360071#M84706</link>
      <description>&lt;P&gt;Thanks, I had a hunch the answer would invlove sharpening my SQL skills. I will give this a whirl later today.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 17:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360071#M84706</guid>
      <dc:creator>CurtisSmithDCAA</dc:creator>
      <dc:date>2017-05-19T17:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360144#M84731</link>
      <description>&lt;P&gt;If you search the Base SAS Programming board for "fuzzy match" you'll find a number of related posts and solutions.&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 22:34:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360144#M84731</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-19T22:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360169#M84744</link>
      <description>&lt;P&gt;Or Perl Regurlar Expression could you more power.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data master;
  input Contract $ Dollars;
  cards;
abc        1000
BCD98765        5000
XYZ99999        100
;

data lookup;
  input Contract$ Customer $;
  cards;
ABC12345       Army
BCD                 Navy
XYZ99999       Air Force
;

proc sql ;
    SELECT a.*, b.Customer,b.Contract as b
      FROM master a
       inner JOIN lookup b
         ON prxmatch(cats('/^',a.Contract,'/i'),b.Contract) or 
            prxmatch(cats('/^',b.Contract,'/i'),a.Contract)
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 May 2017 03:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360169#M84744</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-20T03:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360736#M84994</link>
      <description>&lt;P&gt;I used this method on my 12.4 million row master table. After 24 hours I stopped it. It processed about 1/4 of the master table, but does have a match for each row. I'm going to visually inspect the matching to see if it appears to be accurate. Then, I may subset the master table and run the process in pieces, unless anyone has an idea how to make this run more efficiently. I could try indexing both the master table and the lookup table, but I don't know if indexes matter to this matching process. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 13:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360736#M84994</guid>
      <dc:creator>CurtisSmithDCAA</dc:creator>
      <dc:date>2017-05-23T13:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360739#M84995</link>
      <description>&lt;P&gt;If you have a big table, then it is not suited for SQL.&lt;/P&gt;
&lt;P&gt;Hash Table + Data Step might be more efficient.&lt;/P&gt;
&lt;P&gt;What size of these two tables ?&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 13:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360739#M84995</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-23T13:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360741#M84996</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/101819"&gt;@CurtisSmithDCAA&lt;/a&gt;: Did you try the LIKE operator or the regular expression method? I would think that 12.4 Million records should not have posed any problem, in itself, for PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 14:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360741#M84996</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-23T14:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360742#M84997</link>
      <description>The master table is 12.4 million rows. The lookup table is about 1,000 rows.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 23 May 2017 14:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360742#M84997</guid>
      <dc:creator>CurtisSmithDCAA</dc:creator>
      <dc:date>2017-05-23T14:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360750#M85000</link>
      <description>&lt;P&gt;Yeah. Try&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;'s SQL + LIKE firstly .&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 14:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360750#M85000</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-23T14:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360753#M85002</link>
      <description>&lt;P&gt;Also need consider this scenario .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; master&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Contract &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt; Dollars&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;  &lt;SPAN class="token keyword"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;
BCD        5000
&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; lookup&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; Contract&lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt; Customer &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;  &lt;SPAN class="token keyword"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;
XXBCDXX                Navy
&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 14:16:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360753#M85002</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-23T14:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360759#M85005</link>
      <description>&lt;P&gt;The SQL with the LIKE operator did run after several hours but the resulting table had more rows than the master table. I have not had a chance to diagnose why. The method with the Perl Regurlar Expression&amp;nbsp;seems to work without creating addiditonal rows, but at the rate it was running would take about 4 days to complete.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 14:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360759#M85005</guid>
      <dc:creator>CurtisSmithDCAA</dc:creator>
      <dc:date>2017-05-23T14:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360765#M85009</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/101819"&gt;@CurtisSmithDCAA&lt;/a&gt;: I think you just have to add DISTINCT to your select statement. Otherwise, you'll get multiple rows if there are both partial and full matches. e.g.:&lt;/P&gt;
&lt;PRE&gt;data master;
  input Contract $ Dollars;
  cards;
ABC12345        1000
BCD98765        5000
XYZ99999        100
;

data lookup;
  input Contract$ Customer $;
  cards;
ABC12345       Army
BCD            Navy
BCD98765       Navy
XYZ99999       Air Force
;

proc sql noprint;
  create table want as
    SELECT distinct a.*, b.Customer
      FROM master a
       left JOIN lookup b
         ON a.Contract LIKE catt('%', b.Contract, '%') 
  ;
quit;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 14:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360765#M85009</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-23T14:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360793#M85014</link>
      <description>Thanks. I'll give distinct a try this evening and let it run overnight. I'm&lt;BR /&gt;a Data Step guy, learning SQL as I go.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 23 May 2017 15:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360793#M85014</guid>
      <dc:creator>CurtisSmithDCAA</dc:creator>
      <dc:date>2017-05-23T15:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360808#M85018</link>
      <description>Yes, I am starting to find some items in the lookup table that are more&lt;BR /&gt;complicated than I initially thought. When I find a solution that works, I&lt;BR /&gt;will have a great tool for the future.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Tue, 23 May 2017 15:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/360808#M85018</guid>
      <dc:creator>CurtisSmithDCAA</dc:creator>
      <dc:date>2017-05-23T15:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/361160#M85134</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I think I only consider about START WITH ( =: ), you also consider about CONTAINS &amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.X.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BB&lt;/P&gt;
&lt;P&gt;XXBBXX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;your sql will matched it, but PRX would not .&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 12:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/361160#M85134</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-24T12:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/361204#M85149</link>
      <description>&lt;P&gt;Here is Hash Table solution ,maybe could get you a little faster.&lt;/P&gt;
&lt;P&gt;NOTE: I matched it with START WITH , not all like Arthur's CONTAINS .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data master;
  input Contract $ Dollars;
  cards;
ABC        1000
BCD98765        5000
XYZ99999        100
;

data lookup;
  input Contract$ Customer $;
  cards;
ABC12345       Army
BCD                 Navy
XYZ99999       Air Force
;

data want;
 if _n_=1 then do;
  if 0 then set lookup(rename=(Contract=_Contract));
  declare hash h(dataset:'lookup(rename=(Contract=_Contract))',multidata:'y');
  declare hiter hi('h');
  h.definekey('_Contract');
  h.definedata('_Contract','Customer ');
  h.definedone();
 end;
set master;
do while(hi.next()=0);
 if Contract =: strip(_Contract) or _Contract =: strip(Contract) then output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 May 2017 13:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/361204#M85149</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-24T13:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Merging on a Partial/Prefix Key</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/361211#M85151</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data master;
  input Contract $ Dollars;
  cards;
ABC        1000
BCD98765        5000
XYZ99999        100
;

data lookup;
  input Contract$ Customer $;
  cards;
ABC12345       Army
BCD                 Navy
XYZ99999       Air Force
;

data want;
 if _n_=1 then do;
  if 0 then set lookup(rename=(Contract=_Contract));
  declare hash h(dataset:'lookup(rename=(Contract=_Contract))',multidata:'y');
  declare hiter hi('h');
  h.definekey('_Contract');
  h.definedata('_Contract','Customer ');
  h.definedone();
 end;
set master;
do while(hi.next()=0);
 if strip(Contract) =: _Contract or strip(_Contract) =: Contract then output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 May 2017 13:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-on-a-Partial-Prefix-Key/m-p/361211#M85151</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-24T13:49:54Z</dc:date>
    </item>
  </channel>
</rss>

