<?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: Any idea on how to generate customized Hpsplit Tree Rule? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465284#M24212</link>
    <description>Hi PGStats,&lt;BR /&gt;&lt;BR /&gt;Thank you for your response. I did try to use rule file but I have issue calling the txt file from my sas server library because at the end, the rule files have to be included in my pdf report. Additionally, since I am only interested in certain rules, I think if I can create my own tree rules from Nodestates file, it would be easier.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;( In my case, I have 72 rule files needed to include in pdf report and I’ll have to manually clean the rules I don’t need and copy paste into pdf if I did not figure out any easier way to do it).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sat, 26 May 2018 20:50:29 GMT</pubDate>
    <dc:creator>Vi_</dc:creator>
    <dc:date>2018-05-26T20:50:29Z</dc:date>
    <item>
      <title>Any idea on how to generate customized Hpsplit Tree Rule?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465188#M24210</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if specific output nodestates= option in Proc HPSPLIT, it will give you a table that I think is the key to generate the tree rule.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I need a code that can read like when Node(ID column)=3, parent node (PARENT column)=1, go back to ID column and find the rule (DECISION column) for ID=1 recursively until reach root node.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 336px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20788iE442925086D59363/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(I am using Enterprise Guide 7.1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Vi&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;&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>Fri, 25 May 2018 18:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465188#M24210</guid>
      <dc:creator>Vi_</dc:creator>
      <dc:date>2018-05-25T18:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Any idea on how to generate customized Hpsplit Tree Rule?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465281#M24211</link>
      <description>&lt;P&gt;HPSPLIT now has the RULES statement that creates a text version of the rules that define the leaves of the final tree&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_hpsplit_syntax11.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;http://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_hpsplit_syntax11.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 26 May 2018 20:27:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465281#M24211</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-26T20:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Any idea on how to generate customized Hpsplit Tree Rule?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465284#M24212</link>
      <description>Hi PGStats,&lt;BR /&gt;&lt;BR /&gt;Thank you for your response. I did try to use rule file but I have issue calling the txt file from my sas server library because at the end, the rule files have to be included in my pdf report. Additionally, since I am only interested in certain rules, I think if I can create my own tree rules from Nodestates file, it would be easier.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;( In my case, I have 72 rule files needed to include in pdf report and I’ll have to manually clean the rules I don’t need and copy paste into pdf if I did not figure out any easier way to do it).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 26 May 2018 20:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465284#M24212</guid>
      <dc:creator>Vi_</dc:creator>
      <dc:date>2018-05-26T20:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Any idea on how to generate customized Hpsplit Tree Rule?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465287#M24213</link>
      <description>&lt;P&gt;Understood. This code fragment might be useful. I did this some time ago to format the rules from a binary tree (it probably doesn't work for just any decision tree)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc hpsplit...;
...;
output nodestats = SplitNS;
...;
run;

proc sql;
create unique index Id on SplitNS (Id);
quit;

data Leaves;
set SplitNS;
if not missing(leaf) then do;
    leafNo = leaf;
    leafPop = n;
    value = predictedvalue;
    output;
    id = parent;
    do while (id &amp;gt;= 0);
        set SplitNS key=Id/unique;
        output;
        id = parent;
        end;
    end;
keep leafNo depth leafPop id decision insplitvar value;
run;

proc sort data=Leaves; by leafNo leafPop inSplitVar depth; run;

data LeafText;
length ds str $128;
do until(last.inSplitVar);
    set Leaves; by leafNo inSplitVar;
    /* Remove "or Missing" from decision since there were no missing value in data (optional) */
    decision = left(prxChange('s/or Missing//o', -1, decision));
    select (first(decision));
        when ('&amp;lt;') lt = min(lt, input(scan(substr(decision,2),1," "),best.));
        when ('&amp;gt;') ge = max(ge, input(scan(substr(decision,3),1," "),best.));
        otherwise if missing(ds) or length(ds) &amp;gt; length(decision) then ds = decision;
        end;
    end;

if cmiss(ge, lt) = 0    then str = catx(" - ", ge, lt);
else if not missing(ge) then str = catx(" ", ge, "-");
else if not missing(lt) then str = catx(" ", "-", lt);
else if not missing(ds) then str = ds;

keep leafNo leafPop value inSplitVar str; 
run;

proc transpose data=LeafText out=LeafCond(drop=_name_);
where inSplitVar is not missing;
by leafNo leafPop value;
id inSplitVar;
var str;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 May 2018 21:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465287#M24213</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-26T21:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Any idea on how to generate customized Hpsplit Tree Rule?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465347#M24225</link>
      <description>&lt;P&gt;Hi PG,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you and your code works in my case. But I have some questions and hopefully you can help me on them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. why create unique index on ID column. Aren't they already unique?&lt;/P&gt;&lt;P&gt;2. I don't fully understand this part of code:&amp;nbsp; (why when ID=Parent do something? and what's the code doing under this part?)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    id = parent;
    do while (id &amp;gt;= 0);
        set Node key=Id/unique;
        output;
        id = parent;
        end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Vi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 May 2018 17:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465347#M24225</guid>
      <dc:creator>Vi_</dc:creator>
      <dc:date>2018-05-27T17:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Any idea on how to generate customized Hpsplit Tree Rule?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465352#M24228</link>
      <description>&lt;P&gt;1) The index is created to allow random access to the parent records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) This is precisely where the index comes in. This loop goes up the parent list (from the leaf to the root of the tree) and outputs every record along the way.The code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;id = parent;
set Node key=Id/unique;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;replaces the current record with the parent of the current record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 May 2018 19:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Any-idea-on-how-to-generate-customized-Hpsplit-Tree-Rule/m-p/465352#M24228</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-05-27T19:38:09Z</dc:date>
    </item>
  </channel>
</rss>

