<?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 How to keep a certain level of the clusters from de Proc Cluster in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-keep-a-certain-level-of-the-clusters-from-de-Proc-Cluster/m-p/648509#M31119</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran a proc cluster on the&amp;nbsp;proc corresp output. I obtain a tree (see picture below), and the output table (see table attached).&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tree.PNG" style="width: 842px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39552i1D5F5EEC717F4AD6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tree.PNG" alt="Tree.PNG" /&gt;&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;In the table (Ward), I have in front of each of my variables, the name of (what I believe to be) the smallest cluster I can get. What i'd like,&amp;nbsp; one of my&amp;nbsp;most cherished dreams, is having several columns in my Ward table, each column representing one level of clustering.&lt;BR /&gt;For instance Var_Level_1 : Cluster_1 ; Cluster_2&lt;/P&gt;
&lt;P&gt;Var_Level_2 : Cluster_1_1 ; Cluster_1_2 ; Cluster_2_1 ; Cluster_2_2 etc...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you by advance for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 May 2020 10:24:21 GMT</pubDate>
    <dc:creator>Mathis1</dc:creator>
    <dc:date>2020-05-18T10:24:21Z</dc:date>
    <item>
      <title>How to keep a certain level of the clusters from de Proc Cluster</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-keep-a-certain-level-of-the-clusters-from-de-Proc-Cluster/m-p/648509#M31119</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran a proc cluster on the&amp;nbsp;proc corresp output. I obtain a tree (see picture below), and the output table (see table attached).&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tree.PNG" style="width: 842px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39552i1D5F5EEC717F4AD6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tree.PNG" alt="Tree.PNG" /&gt;&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;In the table (Ward), I have in front of each of my variables, the name of (what I believe to be) the smallest cluster I can get. What i'd like,&amp;nbsp; one of my&amp;nbsp;most cherished dreams, is having several columns in my Ward table, each column representing one level of clustering.&lt;BR /&gt;For instance Var_Level_1 : Cluster_1 ; Cluster_2&lt;/P&gt;
&lt;P&gt;Var_Level_2 : Cluster_1_1 ; Cluster_1_2 ; Cluster_2_1 ; Cluster_2_2 etc...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you by advance for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 May 2020 10:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-keep-a-certain-level-of-the-clusters-from-de-Proc-Cluster/m-p/648509#M31119</guid>
      <dc:creator>Mathis1</dc:creator>
      <dc:date>2020-05-18T10:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep a certain level of the clusters from de Proc Cluster</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-keep-a-certain-level-of-the-clusters-from-de-Proc-Cluster/m-p/648602#M31127</link>
      <description>&lt;P&gt;A set of &lt;CODE&gt;_NAME_ _PARENT_&lt;/CODE&gt;&amp;nbsp;data nodes define a hierarchical tree. From node X, following the data up the parent linkage, to the root is an ancestors path.&amp;nbsp; You want data columns , 1..N, containing the names from root to X.&amp;nbsp; The data node can be stored in a DATA step HASH object and ancestral path traversal can be performed using a series of FIND() operations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The number of steps it takes to traverse from a given node to the root is the depth of the node.&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-family: inherit;"&gt;Suppose you have some longest path P &amp;gt; Q &amp;gt; R &amp;gt; S &amp;gt; T &amp;gt; U &amp;gt; V &amp;gt; W which is length depth 7.&lt;/SPAN&gt;&lt;BR /&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN style="font-family: inherit;"&gt;You know you will need to have 7 columns to capture the pieces of the longest path.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-family: inherit;"&gt;This determination (computation) needs to be done before a final DATA step.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-family: inherit;"&gt;Suppose you have another path A &amp;gt; B &amp;gt; C &amp;gt; D of depth 3.&lt;/SPAN&gt;
&lt;UL&gt;
&lt;LI&gt;&amp;nbsp;Traversing up the parent links from D you have
&lt;UL&gt;
&lt;LI&gt;step 1 C&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;step 2 B&lt;/LI&gt;
&lt;LI&gt;step 3 A&lt;/LI&gt;
&lt;LI&gt;step 4 done&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Arrayed, the traversal is in reverse order C B A, you want the data as A B C.
&lt;UL&gt;
&lt;LI&gt;The data captured during traversal needs to be reversed&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;* pass 1 - compute number of columns needed;
* find longest path;
data _null_;
  if 0 then set download.ward; * prep pdv;

  declare hash links (dataset:'download.ward');
  links.defineKey('_NAME_');
  links.defineData('_PARENT_');
  links.defineDone();

  declare hiter iter('links');

  do index=1 by 1 while (iter.next() = 0);
    do step = 1 by 1 while (links.find(key:_parent_) eq 0);
      if _parent_ = '' then leave;
    end;
    max_step = max (max_step, step);
  end;

  call symput ('MAX_DEPTH', cats(max_step));
run;                               

%put NOTE: &amp;amp;=MAX_DEPTH;

* final step;
data have;
  length depth 8;

  length level1-level&amp;amp;MAX_DEPTH $25;
  array level level1-level&amp;amp;MAX_DEPTH;

  set download.ward;

  if _n_ = 1 then do;
    declare hash links (dataset:'download.ward');
    links.defineKey('_NAME_');
    links.defineData('_PARENT_');
    links.defineDone();     
  end;

  * determine depth (number of steps to root) and capture tiers;
  * in this loop 'level' actually means 'ancestor';
  orig_parent = _parent_;
  level(1) = _parent_;
  do step = 2 by 1 while (links.find(key:_parent_) eq 0);
    if _parent_ = '' then leave;
    level(step) = _parent_;
  end;
  _parent_ = orig_parent;
  depth = step - 1;

  * reverse the the captured tiers;
  do step = 1 to depth/2;

    opstep = depth - step + 1;

    hold = level(step);
    level(step) = level(opstep);
    level(opstep) = hold;
  end;

  drop step opstep hold orig_parent;
run;                               &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 10:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-keep-a-certain-level-of-the-clusters-from-de-Proc-Cluster/m-p/648602#M31127</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-05-20T10:00:15Z</dc:date>
    </item>
  </channel>
</rss>

