<?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: Continual Matching of Records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/740611#M231392</link>
    <description>&lt;P&gt;Hi All - the 3rd link has code that worked to solve my problem.&amp;nbsp; On my full dataset, I had records where the ID2 was blank (see below).&amp;nbsp; I wound up setting those values equal to ID1, and that created clusters which were either 1 record (no matches), 2 matches (natural pair) or 3+ records within the cluster (which are outliers in my data).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to all who provided assistance.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;HAVE&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;ID1 ID2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;
&lt;P&gt;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; Z&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;HAVE_UPDATED&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;ID1&amp;nbsp; ID2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp;Y&lt;/P&gt;
&lt;P&gt;Y&amp;nbsp; &amp;nbsp;Z&lt;/P&gt;</description>
    <pubDate>Tue, 11 May 2021 20:51:34 GMT</pubDate>
    <dc:creator>adornodj</dc:creator>
    <dc:date>2021-05-11T20:51:34Z</dc:date>
    <item>
      <title>Continual Matching of Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739886#M231000</link>
      <description>&lt;P&gt;I have a data set where I want to find all related records, and provide an ID to group them together.&amp;nbsp; I think an array, or some kind of loop, but I'm not 100% certain the way to go.&amp;nbsp; Below is an example on what I am looking to do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;ID&amp;nbsp;&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;Corresponding_Match&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Z&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this example, record 1,2, and 5 would be my first related group; record 3 and 6 would also group together.&amp;nbsp; &amp;nbsp;Ideally, each grouping would get a unique ID corresponding to them.&amp;nbsp; For example 1,2,5 would be UNIQUE1 and 3,6 would be UNIQUE2.&amp;nbsp; I'm operating on SAS EG with no additional add-ons or licenses other than the base package.&amp;nbsp; Any help is appreciated.&amp;nbsp; Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 20:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739886#M231000</guid>
      <dc:creator>adornodj</dc:creator>
      <dc:date>2021-05-07T20:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Continual Matching of Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739898#M231002</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are all very similar to your question. Do any of them work for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466861" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466861&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Data-Management/recursive-joins-with-PROC-SQL/m-p/411824" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Management/recursive-joins-with-PROC-SQL/m-p/411824&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Recursive-lookup-for-ID-s/m-p/259635" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Recursive-lookup-for-ID-s/m-p/259635&lt;/A&gt;&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/215002"&gt;@adornodj&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a data set where I want to find all related records, and provide an ID to group them together.&amp;nbsp; I think an array, or some kind of loop, but I'm not 100% certain the way to go.&amp;nbsp; Below is an example on what I am looking to do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;ID&amp;nbsp;&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;U&gt;Corresponding_Match&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; X&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Y&lt;/P&gt;
&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Z&lt;/P&gt;
&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example, record 1,2, and 5 would be my first related group; record 3 and 6 would also group together.&amp;nbsp; &amp;nbsp;Ideally, each grouping would get a unique ID corresponding to them.&amp;nbsp; For example 1,2,5 would be UNIQUE1 and 3,6 would be UNIQUE2.&amp;nbsp; I'm operating on SAS EG with no additional add-ons or licenses other than the base package.&amp;nbsp; Any help is appreciated.&amp;nbsp; Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 20:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739898#M231002</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-07T20:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Continual Matching of Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739911#M231012</link>
      <description>&lt;P&gt;I'm testing some code someone created from the 3rd link you provided me.&amp;nbsp; if that does not work, I'll post a follow up.&amp;nbsp; Thank you!&amp;nbsp; Now that I know it's a "recursive match" that helps greatly.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 22:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739911#M231012</guid>
      <dc:creator>adornodj</dc:creator>
      <dc:date>2021-05-07T22:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Continual Matching of Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739961#M231050</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
infile cards ;
input from $  to $ ;
cards;
1        X
2        1
3         Y
4        Z
5       2
6       3 
;
run;
data full;
  set have end=last;
  if _n_ eq 1 then do;
   declare hash h();
    h.definekey('node');
     h.definedata('node');
     h.definedone();
  end;
  output;
  node=from; h.replace();
  from=to; to=node;
  output;
  node=from; h.replace();
  if last then h.output(dataset:'node');
  drop node;
run;


data want(keep=node household);
declare hash ha(ordered:'a');
declare hiter hi('ha');
ha.definekey('count');
ha.definedata('last');
ha.definedone();
declare hash _ha(hashexp: 20);
_ha.definekey('key');
_ha.definedone();

if 0 then set full;
declare hash from_to(dataset:'full(where=(from is not missing and to is not missing))',hashexp:20,multidata:'y');
 from_to.definekey('from');
 from_to.definedata('to');
 from_to.definedone();

if 0 then set node;
declare hash no(dataset:'node');
declare hiter hi_no('no');
 no.definekey('node');
 no.definedata('node');
 no.definedone();
 

do while(hi_no.next()=0);
 household+1; output;
 count=1;
 key=node;_ha.add();
 last=node;ha.add();
 rc=hi.first();
 do while(rc=0);
   from=last;rx=from_to.find();
   do while(rx=0);
     key=to;ry=_ha.check();
      if ry ne 0 then do;
       node=to;output;rr=no.remove(key:node);
       key=to;_ha.add();
       count+1;
       last=to;ha.add();
      end;
      rx=from_to.find_next();
   end;
   rc=hi.next();
end;
ha.clear();_ha.clear();
end;
stop;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 May 2021 12:47:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739961#M231050</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-08T12:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Continual Matching of Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739963#M231052</link>
      <description>&lt;P&gt;If you have SAS/OR ,try this one:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* Same code as SAS/OR */
proc optnet data_links=have out_nodes=want GRAPH_DIRECTION=UNDIRECTED;
data_links_var from=from to=to;
concomp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 May 2021 12:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/739963#M231052</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-08T12:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Continual Matching of Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/740168#M231150</link>
      <description>&lt;P&gt;Hello thank you for the response.&amp;nbsp; I am testing out the logics today.&amp;nbsp; Very grateful to the code you all have sent me.&amp;nbsp; Truly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 13:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/740168#M231150</guid>
      <dc:creator>adornodj</dc:creator>
      <dc:date>2021-05-10T13:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Continual Matching of Records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/740611#M231392</link>
      <description>&lt;P&gt;Hi All - the 3rd link has code that worked to solve my problem.&amp;nbsp; On my full dataset, I had records where the ID2 was blank (see below).&amp;nbsp; I wound up setting those values equal to ID1, and that created clusters which were either 1 record (no matches), 2 matches (natural pair) or 3+ records within the cluster (which are outliers in my data).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to all who provided assistance.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;HAVE&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;ID1 ID2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; Y&lt;/P&gt;
&lt;P&gt;Y&amp;nbsp; &amp;nbsp; &amp;nbsp; Z&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;HAVE_UPDATED&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;ID1&amp;nbsp; ID2&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp;Y&lt;/P&gt;
&lt;P&gt;Y&amp;nbsp; &amp;nbsp;Z&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 20:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Continual-Matching-of-Records/m-p/740611#M231392</guid>
      <dc:creator>adornodj</dc:creator>
      <dc:date>2021-05-11T20:51:34Z</dc:date>
    </item>
  </channel>
</rss>

