<?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: Updating Clusters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265371#M52180</link>
    <description>&lt;P&gt;You didn't answer my question yet ?&lt;/P&gt;</description>
    <pubDate>Thu, 21 Apr 2016 09:42:43 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-04-21T09:42:43Z</dc:date>
    <item>
      <title>Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265303#M52158</link>
      <description>&lt;P&gt;This is connection to my previous post found in this link:&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Clustering-Links/m-p/264960#M52032" target="_self"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Clustering-Links/m-p/264960#M52032&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given that I have already performed the household linkages previously, and executed the household tagging again and there were changes, how can I properly update the household tagging.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have provided some sample data as well as the data i'm working on(tmp) to update the clusters. I didn't include my current code to update as it doesn't provide the desired results but I created the desired output for your reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the result,&lt;/P&gt;&lt;P&gt;ids 1,2 retain their old household tag;&lt;/P&gt;&lt;P&gt;id=3 got included on the same household with 1 and 2;&lt;/P&gt;&lt;P&gt;id = 4 retain and id = 5 moved to a different household;&lt;/P&gt;&lt;P&gt;ids 8 and 9 are inserted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any recommendations on how to acheive this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;BR /&gt;data old;
	input household id;
	datalines;
1 1
1 2
2 4
2 5
3 6 
3 7
;

data new;
	input household id;
	datalines;
2 1
2 2
2 3
4 5
4 6
4 7
5 8
5 9
;

proc sql;
	create table tmp as
	select
		a.household,
		coalesce(a.id,b.id) as id,
		b.household as new_household
	from
		old a full outer join new b
	on(a.id=b.id)
	;
quit;

data desired;
	input household id;
	datalines;
1 1
1 2
1 3
2 4
3 5
3 6
3 7
4 8
4 9&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 09:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265303#M52158</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2016-04-21T09:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265322#M52164</link>
      <description>&lt;P&gt;I don't understand what you are talking about.&lt;/P&gt;
&lt;P&gt;What is your table HAVE ? and What is your table WANT ?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 06:21:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265322#M52164</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-21T06:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265328#M52166</link>
      <description>&lt;P&gt;Hi Keshan,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The old and new datasets are my HAVE and the desired table is my WANT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The household ids from old dataset must be retained for each id, given that he didn't move from a different household on the new dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 06:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265328#M52166</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2016-04-21T06:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265331#M52167</link>
      <description>&lt;P&gt;I still can't get your point.&lt;/P&gt;
&lt;P&gt;Could you explain How you could use OLD and NEW to get DESIRE ?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 07:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265331#M52167</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-21T07:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265351#M52176</link>
      <description>&lt;P&gt;I have some spare time, so I am watching for a while .&lt;/P&gt;
&lt;P&gt;Here is a question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In table NEW&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 datalines"&gt;&lt;SPAN class="token data string"&gt;4 5 -&amp;gt; 2
4 6 -&amp;gt; 3
4 7 -&amp;gt; 3&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;So you got &lt;BR /&gt;5 3&lt;BR /&gt;6 3&lt;BR /&gt;7 3&lt;BR /&gt;What if 5 6 7 map into different OLD household Like , what you are going to do ?&lt;BR /&gt;&lt;BR /&gt;4 5 -&amp;gt; 2&lt;BR /&gt;4 6 -&amp;gt; 3&lt;BR /&gt;4 7 -&amp;gt; 4&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 08:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265351#M52176</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-21T08:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265352#M52177</link>
      <description>&lt;P&gt;Old contains let's say the first run using the hash lookup solution you created (thanks again for that one!). So that one created this household grouping&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;household 1 - {1,4}&lt;/P&gt;&lt;P&gt;household 2 - {4,5}&lt;/P&gt;&lt;P&gt;household 3 - {6,7}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the future I would like to execute this household exercise again, chances are the household ids we used will not be the same as its incremental, so that new run will have something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;household 2&amp;nbsp;- {1,2,3}&lt;/P&gt;&lt;P&gt;household 4&amp;nbsp;- {5,6,7}&lt;/P&gt;&lt;P&gt;household 5&amp;nbsp;- {8,9} (new household not existing in the previous run)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next thing I want to do is to match the original result&amp;nbsp;and the new result. using the household ids there as still the "real ids".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;household 1 - {1,2,3}&lt;/P&gt;&lt;P&gt;household 2 - {4}&amp;nbsp;&lt;/P&gt;&lt;P&gt;household 3 - {5,6,7} (id 5 will have its household replaced from 2 to 3)&lt;/P&gt;&lt;P&gt;household 4 - {8,9} (inserted to the original set, then getting the max + 1 as household id)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you're questioning why 5 got moved to a different household, this is&amp;nbsp;an example that there was no links between 4 and 5, but 5,6,7 had so it moved to a different household.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry if my explanation is a bit confusing.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 08:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265352#M52177</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2016-04-21T08:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265371#M52180</link>
      <description>&lt;P&gt;You didn't answer my question yet ?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 09:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265371#M52180</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-21T09:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265372#M52181</link>
      <description>&lt;P&gt;For this instance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id -&amp;gt; household&lt;/P&gt;&lt;P&gt;5 -&amp;gt; 3 (assuming it's the first record to be processed)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then the max household id of the original should be identified (which is 4) then increment to assign household to id 6 and 7&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;id -&amp;gt; household&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;6 -&amp;gt; 5&lt;/P&gt;&lt;P&gt;7 -&amp;gt; 6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just noticed one of the confusions I guess I put in values wrongly in the desired earlier. My apologies on that.&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; desired&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; household &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	datalines&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;4&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;5&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;7&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;8&lt;/SPAN&gt;
&lt;SPAN class="token number"&gt;4&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;9&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 09:51:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265372#M52181</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2016-04-21T09:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265454#M52202</link>
      <description>&lt;P&gt;I cannot see any realtionship that matches household 4 to id 8 and 9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think there is some conditonal assignment that you are not making the logic clear. I can hard code a result that will create your result but the genera solution is not at all obvious.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the purpose of your posted TMP data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 15:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265454#M52202</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-21T15:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Clusters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265569#M52251</link>
      <description>&lt;P&gt;Yes there is some logic to build the household tagging initially found in this post&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/Clustering-Links/m-p/264960#M52032" target="_self"&gt;https://communities.sas.com/t5/Base-SAS-Programming/Clustering-Links/m-p/264960#M52032&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The TMP dataset was suppose combine the old and new result. But I think it wouldn't work so I had to consult people here in the community who might have better thoughts or approaches on this one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 01:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Updating-Clusters/m-p/265569#M52251</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2016-04-22T01:13:40Z</dc:date>
    </item>
  </channel>
</rss>

