<?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: How do I link together all chained pairs in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-link-together-all-chained-pairs/m-p/560651#M17171</link>
    <description>&lt;P&gt;This isn't a trivial task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it's been asked many times.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a recent answer that's relevant and pretty much what you're trying to do:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466861#M14584" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466861#M14584&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/28988"&gt;@newnoise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've got a data set that looks something like this:&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 pair_data;
	infile datalines missover;
	input var_id $ parent_var_id $;
	datalines;
		1	
		2	1
		3	2
		4	20
		20	
		21	4
		15	3
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally, I want to end up with a data set that combines all nested combinations, including the original ID (which has a blank parent_var value). So, it should look something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combined_pair_data;
	infile datalines missover;
	input combo_id $ var_id $ parent_var_id $;
	datalines;
		1	1	1
		1	2	1
		1	3	2
		2	4	20
		2	20	20
		2	21	4
		1	15	3
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice that any original ID has its own ID filled in as the parent, but all linked combinations are given a sequential combo_id to differentiate chains of pairs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've used do loops up to this point, but that seems inefficient.&lt;STRONG&gt; I imagine there's gotta be a simple way to do this, but I can't put my finger on it.&lt;/STRONG&gt; Any help would be greatly appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looked elsewhere in the forums and didn't see anything like this.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 May 2019 20:27:40 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-05-21T20:27:40Z</dc:date>
    <item>
      <title>How do I link together all chained pairs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-link-together-all-chained-pairs/m-p/560648#M17170</link>
      <description>&lt;P&gt;I've got a data set that looks something like this:&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 pair_data;
	infile datalines missover;
	input var_id $ parent_var_id $;
	datalines;
		1	
		2	1
		3	2
		4	20
		20	
		21	4
		15	3
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally, I want to end up with a data set that combines all nested combinations, including the original ID (which has a blank parent_var value). So, it should look something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combined_pair_data;
	infile datalines missover;
	input combo_id $ var_id $ parent_var_id $;
	datalines;
		1	1	1
		1	2	1
		1	3	2
		2	4	20
		2	20	20
		2	21	4
		1	15	3
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice that any original ID has its own ID filled in as the parent, but all linked combinations are given a sequential combo_id to differentiate chains of pairs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've used do loops up to this point, but that seems inefficient. I imagine there's gotta be a simple way to do this, but I can't put my finger on it. Any help would be greatly appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looked elsewhere in the forums and didn't see anything like this.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 20:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-link-together-all-chained-pairs/m-p/560648#M17170</guid>
      <dc:creator>newnoise</dc:creator>
      <dc:date>2019-05-21T20:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I link together all chained pairs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-link-together-all-chained-pairs/m-p/560651#M17171</link>
      <description>&lt;P&gt;This isn't a trivial task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it's been asked many times.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a recent answer that's relevant and pretty much what you're trying to do:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466861#M14584" target="_blank"&gt;https://communities.sas.com/t5/SAS-Data-Management/Recursive-Query/m-p/466861#M14584&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/28988"&gt;@newnoise&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've got a data set that looks something like this:&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 pair_data;
	infile datalines missover;
	input var_id $ parent_var_id $;
	datalines;
		1	
		2	1
		3	2
		4	20
		20	
		21	4
		15	3
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ideally, I want to end up with a data set that combines all nested combinations, including the original ID (which has a blank parent_var value). So, it should look something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data combined_pair_data;
	infile datalines missover;
	input combo_id $ var_id $ parent_var_id $;
	datalines;
		1	1	1
		1	2	1
		1	3	2
		2	4	20
		2	20	20
		2	21	4
		1	15	3
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice that any original ID has its own ID filled in as the parent, but all linked combinations are given a sequential combo_id to differentiate chains of pairs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've used do loops up to this point, but that seems inefficient.&lt;STRONG&gt; I imagine there's gotta be a simple way to do this, but I can't put my finger on it.&lt;/STRONG&gt; Any help would be greatly appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looked elsewhere in the forums and didn't see anything like this.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 20:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-link-together-all-chained-pairs/m-p/560651#M17171</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-21T20:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I link together all chained pairs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-link-together-all-chained-pairs/m-p/560656#M17172</link>
      <description>Ah, my apologies! I hadn't seen the other post(s) and wasn't familiar with the 'recursive' descriptor for this situation. Thanks for pointing me in direction of an answer!</description>
      <pubDate>Tue, 21 May 2019 20:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-do-I-link-together-all-chained-pairs/m-p/560656#M17172</guid>
      <dc:creator>newnoise</dc:creator>
      <dc:date>2019-05-21T20:31:55Z</dc:date>
    </item>
  </channel>
</rss>

