<?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: Match Data on a different row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Match-Data-on-a-different-row/m-p/631404#M187086</link>
    <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/29035"&gt;@NewSASPerson&lt;/a&gt;&amp;nbsp; Curious fun puzzle, spicing up with HASH&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input name1$ name2 $ ;
datalines;
Mark Jones
Jones Mark
Jane Doe
Doe Jane
John Doe
Susy Z
John Smith
;
run;

data want ;
 if _n_=1 then do;
   dcl hash H (ordered: "A") ;
   h.definekey  ("name1","name2") ;
   h.definedone () ;
 end;
 set have;
 if h.check() ne 0 and h.check(key:name2,key:name1) ne 0;
 h.add();
run;

proc print noobs;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;name1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;name2&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Mark&lt;/TD&gt;
&lt;TD class="l data"&gt;Jones&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Jane&lt;/TD&gt;
&lt;TD class="l data"&gt;Doe&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;John&lt;/TD&gt;
&lt;TD class="l data"&gt;Doe&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Susy&lt;/TD&gt;
&lt;TD class="l data"&gt;Z&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;John&lt;/TD&gt;
&lt;TD class="l data"&gt;Smith&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Wed, 11 Mar 2020 22:13:55 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-03-11T22:13:55Z</dc:date>
    <item>
      <title>Match Data on a different row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-Data-on-a-different-row/m-p/631389#M187079</link>
      <description>&lt;P&gt;I would like to&amp;nbsp; keep one record when the names are the same. for example in my sample data, Mark Jones &amp;amp; Jones Mark are the same and I only want to keep on record, not both.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input name1$ name2 $ ;
datalines;
Mark Jones
Jones Mark
Jane Doe
Doe Jane
John Doe
Susy Z
John Smith
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would appreciate some help&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 21:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-Data-on-a-different-row/m-p/631389#M187079</guid>
      <dc:creator>NewSASPerson</dc:creator>
      <dc:date>2020-03-11T21:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Match Data on a different row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-Data-on-a-different-row/m-p/631391#M187080</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name1$ name2 $ ;
call sort(name1,name2);
datalines;
Mark Jones
Jones Mark
Jane Doe
Doe Jane
John Doe
Susy Z
John Smith
;
run;

proc sort data=have out=want nodupkey;
    by name1 name2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Naturally, this doesn't account for spelling errors, middle name or middle initials (it might not account for capitalization differences but that's easy to fix) or other problem with the recording of people's names. It does handle properly names that are palindromes.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 21:41:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-Data-on-a-different-row/m-p/631391#M187080</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-11T21:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: Match Data on a different row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-Data-on-a-different-row/m-p/631404#M187086</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/29035"&gt;@NewSASPerson&lt;/a&gt;&amp;nbsp; Curious fun puzzle, spicing up with HASH&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input name1$ name2 $ ;
datalines;
Mark Jones
Jones Mark
Jane Doe
Doe Jane
John Doe
Susy Z
John Smith
;
run;

data want ;
 if _n_=1 then do;
   dcl hash H (ordered: "A") ;
   h.definekey  ("name1","name2") ;
   h.definedone () ;
 end;
 set have;
 if h.check() ne 0 and h.check(key:name2,key:name1) ne 0;
 h.add();
run;

proc print noobs;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;name1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;name2&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Mark&lt;/TD&gt;
&lt;TD class="l data"&gt;Jones&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Jane&lt;/TD&gt;
&lt;TD class="l data"&gt;Doe&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;John&lt;/TD&gt;
&lt;TD class="l data"&gt;Doe&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;Susy&lt;/TD&gt;
&lt;TD class="l data"&gt;Z&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;John&lt;/TD&gt;
&lt;TD class="l data"&gt;Smith&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 11 Mar 2020 22:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-Data-on-a-different-row/m-p/631404#M187086</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-11T22:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Match Data on a different row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-Data-on-a-different-row/m-p/631406#M187087</link>
      <description>&lt;P&gt;Thanks for the caveat! This worked for my actual data set. I appreciate the help&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 22:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-Data-on-a-different-row/m-p/631406#M187087</guid>
      <dc:creator>NewSASPerson</dc:creator>
      <dc:date>2020-03-11T22:26:20Z</dc:date>
    </item>
  </channel>
</rss>

