<?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: Matching data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422555#M103917</link>
    <description>&lt;P&gt;if codes only consist of Match1, then the value=0 -- in this case, if code1= A_A (both are Match1 values) then result=0&lt;/P&gt;</description>
    <pubDate>Wed, 20 Dec 2017 00:35:19 GMT</pubDate>
    <dc:creator>ursula</dc:creator>
    <dc:date>2017-12-20T00:35:19Z</dc:date>
    <item>
      <title>Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422534#M103911</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I tried to match 2 file to generate a new file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;see below example:&lt;/P&gt;
&lt;P&gt;File 1:&lt;/P&gt;
&lt;TABLE width="360"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;ID&lt;/TD&gt;
&lt;TD width="72"&gt;code1&lt;/TD&gt;
&lt;TD width="72"&gt;code2&lt;/TD&gt;
&lt;TD width="72"&gt;code3&lt;/TD&gt;
&lt;TD width="72"&gt;code4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;TD&gt;A_B&lt;/TD&gt;
&lt;TD&gt;C_D&lt;/TD&gt;
&lt;TD&gt;A_C&lt;/TD&gt;
&lt;TD&gt;B_D&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;File 2:&lt;/P&gt;
&lt;TABLE width="216"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;Code&lt;/TD&gt;
&lt;TD width="72"&gt;Match1&lt;/TD&gt;
&lt;TD width="72"&gt;Match2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code1&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code2&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code3&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code4&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;look into code1 in file1: A_B, A_A_, B_B. I want to see if it matches with Code1 in File2 variable Match2, in this case Match2 =B&lt;/P&gt;
&lt;P&gt;if code1 in file1 only match 1 letter then the result will be 1, if match 2 letter then the result will be 2, if No match then the result will be 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is what I want.&lt;/P&gt;
&lt;TABLE width="648"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;ID&lt;/TD&gt;
&lt;TD width="72"&gt;code1&lt;/TD&gt;
&lt;TD width="72"&gt;Result1&lt;/TD&gt;
&lt;TD width="72"&gt;code2&lt;/TD&gt;
&lt;TD width="72"&gt;Result2&lt;/TD&gt;
&lt;TD width="72"&gt;code3&lt;/TD&gt;
&lt;TD width="72"&gt;Result3&lt;/TD&gt;
&lt;TD width="72"&gt;code4&lt;/TD&gt;
&lt;TD width="72"&gt;Result4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;TD&gt;A_B&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;C_D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;A_C&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;B_D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there a SAS code that can run for generating the results for all variables ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope it's not confusing you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you need more information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 23:21:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422534#M103911</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-12-19T23:21:30Z</dc:date>
    </item>
    <item>
      <title>Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422535#M103914</link>
      <description>&lt;DIV class="lia-message-heading lia-component-message-header"&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;
&lt;DIV class="lia-message-subject"&gt;
&lt;H1&gt;&amp;nbsp;&lt;/H1&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="messagebodydisplay_0" class="lia-message-body"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I tried to match 2 file to generate a new file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;see below example:&lt;/P&gt;
&lt;P&gt;File 1:&lt;/P&gt;
&lt;TABLE width="360"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;ID&lt;/TD&gt;
&lt;TD width="72"&gt;code1&lt;/TD&gt;
&lt;TD width="72"&gt;code2&lt;/TD&gt;
&lt;TD width="72"&gt;code3&lt;/TD&gt;
&lt;TD width="72"&gt;code4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;TD&gt;A_B&lt;/TD&gt;
&lt;TD&gt;C_D&lt;/TD&gt;
&lt;TD&gt;A_C&lt;/TD&gt;
&lt;TD&gt;B_D&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;File 2:&lt;/P&gt;
&lt;TABLE width="216"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;Code&lt;/TD&gt;
&lt;TD width="72"&gt;Match1&lt;/TD&gt;
&lt;TD width="72"&gt;Match2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code1&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code2&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code3&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code4&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;look into code1 in file1: A_B, A_A_, B_B. I want to see if it matches with Code1 in File2 variable Match2, in this case Match2 =B&lt;/P&gt;
&lt;P&gt;if code1 in file1 only match 1 letter then the result will be 1, if match 2 letter then the result will be 2, if No match then the result will be 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is what I want.&lt;/P&gt;
&lt;TABLE width="648"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;ID&lt;/TD&gt;
&lt;TD width="72"&gt;code1&lt;/TD&gt;
&lt;TD width="72"&gt;Result1&lt;/TD&gt;
&lt;TD width="72"&gt;code2&lt;/TD&gt;
&lt;TD width="72"&gt;Result2&lt;/TD&gt;
&lt;TD width="72"&gt;code3&lt;/TD&gt;
&lt;TD width="72"&gt;Result3&lt;/TD&gt;
&lt;TD width="72"&gt;code4&lt;/TD&gt;
&lt;TD width="72"&gt;Result4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;TD&gt;A_B&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;C_D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;A_C&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;B_D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there a SAS code that can run for generating the results for all variables ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope it's not confusing you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you need more information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!!&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 19 Dec 2017 23:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422535#M103914</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-12-19T23:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422541#M103915</link>
      <description>&lt;P&gt;What's Match1 column for then?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34666"&gt;@ursula&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I tried to match 2 file to generate a new file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;see below example:&lt;/P&gt;
&lt;P&gt;File 1:&lt;/P&gt;
&lt;TABLE width="360"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;ID&lt;/TD&gt;
&lt;TD width="72"&gt;code1&lt;/TD&gt;
&lt;TD width="72"&gt;code2&lt;/TD&gt;
&lt;TD width="72"&gt;code3&lt;/TD&gt;
&lt;TD width="72"&gt;code4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;TD&gt;A_B&lt;/TD&gt;
&lt;TD&gt;C_D&lt;/TD&gt;
&lt;TD&gt;A_C&lt;/TD&gt;
&lt;TD&gt;B_D&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;File 2:&lt;/P&gt;
&lt;TABLE width="216"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;Code&lt;/TD&gt;
&lt;TD width="72"&gt;Match1&lt;/TD&gt;
&lt;TD width="72"&gt;Match2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code1&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code2&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code3&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code4&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;look into code1 in file1: A_B, A_A_, B_B. I want to see if it matches with Code1 in File2 variable Match2, in this case Match2 =B&lt;/P&gt;
&lt;P&gt;if code1 in file1 only match 1 letter then the result will be 1, if match 2 letter then the result will be 2, if No match then the result will be 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is what I want.&lt;/P&gt;
&lt;TABLE width="648"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;ID&lt;/TD&gt;
&lt;TD width="72"&gt;code1&lt;/TD&gt;
&lt;TD width="72"&gt;Result1&lt;/TD&gt;
&lt;TD width="72"&gt;code2&lt;/TD&gt;
&lt;TD width="72"&gt;Result2&lt;/TD&gt;
&lt;TD width="72"&gt;code3&lt;/TD&gt;
&lt;TD width="72"&gt;Result3&lt;/TD&gt;
&lt;TD width="72"&gt;code4&lt;/TD&gt;
&lt;TD width="72"&gt;Result4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;TD&gt;A_B&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;C_D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;A_C&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;B_D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there a SAS code that can run for generating the results for all variables ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope it's not confusing you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you need more information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Wed, 20 Dec 2017 00:39:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422541#M103915</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-20T00:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422548#M103916</link>
      <description>&lt;P&gt;Thanks for your response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Match2 is dominant, so we only look into Match2.&lt;/P&gt;
&lt;P&gt;Codes values actually are generating from Match1 and Match2 values.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 00:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422548#M103916</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-12-20T00:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422555#M103917</link>
      <description>&lt;P&gt;if codes only consist of Match1, then the value=0 -- in this case, if code1= A_A (both are Match1 values) then result=0&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 00:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422555#M103917</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-12-20T00:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422557#M103918</link>
      <description>&lt;P&gt;So we can entirely ignore Match1 column?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's the case, I'd probably create an informat from the second table, 1 if it's in the table, 0 otherwise.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FORMAT CNTLIN can be used to create formats from data sets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/forum2007/068-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/068-2007.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then use SCAN to parse the components of your match variable and using INPUT to convert it to a numeric variable that would then get added together. Here's an example below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;match_value = input (scan(original_variable, 1, "_"), $lookup_fmt.) + 
 input (scan(original_variable, 2, "_"), $lookup_fmt.) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would get it working for one case first and then use an array to do it for the several columns you have.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have difficulty post your code, the log and any errors you're receiving.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34666"&gt;@ursula&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Match2 is dominant, so we only look into Match2.&lt;/P&gt;
&lt;P&gt;Codes values actually are generating from Match1 and Match2 values.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 00:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422557#M103918</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-20T00:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422558#M103919</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34666"&gt;@ursula&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;if codes only consist of Match1, then the value=0 -- in this case, if code1= A_A (both are Match1 values) then result=0&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A is also in Match2 column, so wouldn't that be 2 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="216"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;Code&lt;/TD&gt;
&lt;TD width="72"&gt;Match1&lt;/TD&gt;
&lt;TD width="72"&gt;Match2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code1&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code2&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code3&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;A&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;code4&lt;/TD&gt;
&lt;TD&gt;D&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 20 Dec 2017 00:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422558#M103919</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-20T00:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422560#M103920</link>
      <description>&lt;P&gt;If you want tested code you need to provide data in the form of a data step so we can run code against it.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data work.file1;
 input ID $ code1 $ code2 $ code3 $ code4 $;
datalines;
11 A_B C_D A_C B_D 
12 A_A D_D A_A B_B 
14 B_B C_C C_C D_D 
;
run;
 
data work.File2;
   input Code $ Match1 $ Match2 $;
datalines; 
code1 A B 
code2 D C 
code3 C A 
code4 D B 
;
run;&lt;/PRE&gt;
&lt;P&gt;With that in mind, I think you need to go through some very specific details of what is compared to what for counting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you only looking at "match2"? If so, then why is match1 included in the data? If so this gets part of the way there;&lt;/P&gt;
&lt;PRE&gt;proc sort data=work.file1;
   by id;
run;
proc transpose data=work.file1 out=work.ftrans1
;
   by id;
   var code: ;
run;

proc sql;
   create table work.almost as
   select a.id,a._name_,a.col1, countc(a.col1,strip(b.match2)) as result
   from work.ftrans1 as a
        left join
        work.file2 as b
        on a._name_ = b.code
   order by a.id,a._name_,a.col1
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;But I have to leave now and will leave reshaping that last dataset to the desired form for someone else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 00:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422560#M103920</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-20T00:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422562#M103921</link>
      <description>&lt;P&gt;Thank you for the response.&lt;/P&gt;
&lt;P&gt;I appreciate your time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 00:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422562#M103921</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-12-20T00:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422681#M103930</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.file1;
 input ID $ code1 $ code2 $ code3 $ code4 $;
datalines;
11 A_B C_D A_C B_D 
12 A_A D_D A_A B_B 
14 B_B C_C C_C D_D 
;
run;
 
data work.File2;
   input Code $ Match1 $ Match2 $;
datalines; 
code1 A B 
code2 D C 
code3 C A 
code4 D B 
;
run;

data want;
 if _n_=1 then do;
  if 0 then set file2;
  declare hash h(dataset:'file2');
  h.definekey('code','match2');
  h.definedone();
 end;
set file1;
array x{*} code1-code4;
array result{4};
call missing(of result{*});
do i=1 to dim(x);
  _code=vname(x{i}); 
  do j=1 to countw(x{i},'_');
    _match2=scan(x{i},j,'_');
	if h.check(key:_code,key:_match2)=0 then result{i}+1;
  end;
end;
drop _: i j Code  Match1  Match2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Dec 2017 12:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/422681#M103930</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-20T12:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423267#M104064</link>
      <description>&lt;P style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;Hi Ksharp,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;Thank you so much for the advance codes!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;after I run into my real data, I have a little question to make it perfect.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;When I run using your codes, the ones that have two Match1-- see ID12, code1=A_A, the result should be "0" instead of Blank.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;otherwise all are looks good.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;But if ID12, code1 = F_F for example, then the result should be "Blank or missing", because F is not Matching with Match1 and Match2. Does it make sense?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;could you&amp;nbsp;help to fix the code?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;Thanks again for your time.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; margin-bottom: .0001pt; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; widows: 2; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; word-spacing: 0px;"&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica',sans-serif; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;this is what I want.&lt;/P&gt;
&lt;TABLE width="648"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;ID&lt;/TD&gt;
&lt;TD width="72"&gt;code1&lt;/TD&gt;
&lt;TD width="72"&gt;Result1&lt;/TD&gt;
&lt;TD width="72"&gt;code2&lt;/TD&gt;
&lt;TD width="72"&gt;Result2&lt;/TD&gt;
&lt;TD width="72"&gt;code3&lt;/TD&gt;
&lt;TD width="72"&gt;Result3&lt;/TD&gt;
&lt;TD width="72"&gt;code4&lt;/TD&gt;
&lt;TD width="72"&gt;Result4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;11&lt;/TD&gt;
&lt;TD&gt;A_B&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;C_D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;A_C&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;B_D&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;A_A&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;14&lt;/TD&gt;
&lt;TD&gt;B_B&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;C_C&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;D_D&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 22 Dec 2017 07:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423267#M104064</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-12-22T07:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423311#M104081</link>
      <description>&lt;P&gt;"&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;because F is not Matching with Match1 and Match2. Does it make sense?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you said you want match MATCH2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.file1;
 input ID $ code1 $ code2 $ code3 $ code4 $;
datalines;
11 A_B C_D A_C B_D 
12 A_A D_D A_A B_B 
14 B_B C_C C_C D_D 
14 F_F C_C C_C D_D 
;
run;
 
data work.File2;
   input Code $ Match1 $ Match2 $;
datalines; 
code1 A B 
code2 D C 
code3 C A 
code4 D B 
;
run;

data want;
 if _n_=1 then do;
  if 0 then set file2;
  declare hash h(dataset:'file2');
  h.definekey('code','match2');
  h.definedone();
 end;
set file1;
array x{*} code1-code4;
array result{4};

do k=1 to dim(result);
 result{k}=0;
end;

do i=1 to dim(x);
  _code=vname(x{i}); 
  do j=1 to countw(x{i},'_');
    _match2=scan(x{i},j,'_');
	if h.check(key:_code,key:_match2)=0 then result{i}+1;
  end;
end;
drop _: i j k Code  Match1  Match2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Dec 2017 13:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423311#M104081</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-22T13:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423349#M104088</link>
      <description>&lt;P&gt;Hi KShap,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so so much for your quick response!&lt;/P&gt;
&lt;P&gt;I'm so happy almost there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sorry if I was confusing you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I Added one more line into File1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data work.file1;&lt;BR /&gt; input ID $ code1 $ code2 $ code3 $ code4 $;&lt;BR /&gt;datalines;&lt;BR /&gt;11 A_B C_D A_C B_D &lt;BR /&gt;12 A_A D_D A_A B_B &lt;BR /&gt;14 B_B C_C C_C D_D &lt;BR /&gt;14 F_F C_C C_C D_D &lt;BR /&gt;15 F_F F_C C_F F_F&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;data work.File2;&lt;BR /&gt; input Code $ Match1 $ Match2 $;&lt;BR /&gt;datalines; &lt;BR /&gt;code1 A B &lt;BR /&gt;code2 D C &lt;BR /&gt;code3 C A &lt;BR /&gt;code4 D B &lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the result look like this:&lt;/P&gt;
&lt;P&gt;for the "F" issue:&lt;/P&gt;
&lt;P&gt;"Blank" if F_F -- NoMatch1 and NoMatch2.&lt;/P&gt;
&lt;P&gt;see ID15 code3 -- C_F, the result is "Blank" because C is not a Match2, and F is not in File2(see Code3 -- Match2=A) so the result=,(blank)&lt;/P&gt;
&lt;P&gt;see ID15 code2 -- F_C, the result is "1", because C is a Match2 even though it has "F" on it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 432pt;" border="0" width="576" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl63" style="height: 15.0pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;code1&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;code2&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;code3&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;code4&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;result1&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;result2&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;result3&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="border-left: none; width: 48pt;"&gt;result4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;11&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A_B&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;C_D&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A_C&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;B_D&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;12&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A_A&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;D_D&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;A_A&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;B_B&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;14&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;B_B&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;C_C&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;C_C&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;D_D&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;14&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;F_F&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;C_C&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;C_C&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;D_D&lt;/TD&gt;
&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;.&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl63" style="height: 15.0pt; border-top: none;"&gt;15&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;F_F&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;F_C&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;C_F&lt;/TD&gt;
&lt;TD class="xl63" style="border-top: none; border-left: none;"&gt;F_F&lt;/TD&gt;
&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;.&lt;/TD&gt;
&lt;TD align="right" class="xl63" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;.&lt;/TD&gt;
&lt;TD class="xl64" style="border-top: none; border-left: none;"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again for your time.&lt;/P&gt;
&lt;P&gt;Happy Holidays!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 17:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423349#M104088</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-12-22T17:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423441#M104133</link>
      <description>&lt;P&gt;OK. If I understood what you mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.file1;
input ID $ code1 $ code2 $ code3 $ code4 $;
datalines;
11 A_B C_D A_C B_D 
12 A_A D_D A_A B_B 
14 B_B C_C C_C D_D 
14 F_F C_C C_C D_D 
15 F_F F_C C_F F_F
;
run;

data work.File2;
input Code $ Match1 $ Match2 $;
datalines; 
code1 A B 
code2 D C 
code3 C A 
code4 D B 
;
run;

data want;
 if _n_=1 then do;
  if 0 then set file2;
  declare hash h(dataset:'file2');
  h.definekey('code','match2');
  h.definedone();

  declare hash h1(dataset:'file2');
  h1.definekey('match1');
  h1.definedone();
  declare hash h2(dataset:'file2');
  h2.definekey('match2');
  h2.definedone();
 end;
set file1;
array x{*} code1-code4;
array result{4};

do k=1 to dim(result);
 result{k}=0;
end;

do i=1 to dim(x);
  _code=vname(x{i}); 
  do j=1 to countw(x{i},'_');
    _match2=scan(x{i},j,'_');
	if h.check(key:_code,key:_match2)=0 then result{i}+1;
  end;
end;

do i=1 to dim(x);
  if result{i}=0 then do; 
  do j=1 to countw(x{i},'_');
    temp=scan(x{i},j,'_');
	if h1.check(key:temp) ne 0 and h2.check(key:temp) ne 0 then result{i}=.;
  end;
  end;
end;
drop _: i j k Code  Match1  Match2 temp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Dec 2017 11:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423441#M104133</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-12-23T11:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423527#M104167</link>
      <description>&lt;P&gt;Thank you so much! Ksharp!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is exactly what i want!! I really appreciate your time and patience.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This community is very helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy Holidays, KSharp!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Dec 2017 22:17:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data/m-p/423527#M104167</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2017-12-25T22:17:48Z</dc:date>
    </item>
  </channel>
</rss>

