<?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 Using interactive grouping labels in custom SAS EM node in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Using-interactive-grouping-labels-in-custom-SAS-EM-node/m-p/653501#M8296</link>
    <description>&lt;P&gt;I have an Enterprise Miner diagram which does the following: Inputs a dataset -&amp;gt; Partitions into training and validation -&amp;gt; Groups variables using Interactive Grouping -&amp;gt; Creates a credit Scorecard -&amp;gt; Scores up the dataset with the Score node -&amp;gt; Creates a custom report in a SAS Code node.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the last node (SAS Code), I will calculate various statistics, but essentially I need to output a frequency table for grouped variables, using the group labels created by the Interactive Grouping node. The question is how I access those labels.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To illustrate, here's a very simple piece of code that I could use in the SAS Code node:&lt;/P&gt;&lt;PRE&gt;proc freq data=&amp;amp;EM_IMPORT_DATA;
	table GRP_age / norow nocol nopercent nocum missing;
run;&lt;/PRE&gt;&lt;P&gt;The variable 'GRP_age' is created by the Score node using the grouping definitions from Interactive Grouping, and is derived from the input variable 'age'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This creates the following result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;GRP_age Frequency&lt;BR /&gt;--------------------&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 755&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1190&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1302&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1580&lt;BR /&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1100&lt;BR /&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 643&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;...but I would like to see this:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Group Name &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Frequency&lt;BR /&gt;----------------------------&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;age&amp;lt; 32, _MISSING_ &amp;nbsp; &amp;nbsp;&amp;nbsp; 755&lt;BR /&gt;32&amp;lt;= age&amp;lt; 40 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1190&lt;BR /&gt;40&amp;lt;= age&amp;lt; 47 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1302&lt;BR /&gt;47&amp;lt;= age&amp;lt; 56 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1580&lt;BR /&gt;56&amp;lt;= age&amp;lt; 65 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1100&lt;BR /&gt;65&amp;lt;= age &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 643&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Guessing I need to merge in a table from the IG node. Any ideas what this other table is called (in a way that will work if I connect my SAS Code node to a new Interactive Grouping node)?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Thanks!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Tom.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jun 2020 04:13:59 GMT</pubDate>
    <dc:creator>tom_evans_79</dc:creator>
    <dc:date>2020-06-05T04:13:59Z</dc:date>
    <item>
      <title>Using interactive grouping labels in custom SAS EM node</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Using-interactive-grouping-labels-in-custom-SAS-EM-node/m-p/653501#M8296</link>
      <description>&lt;P&gt;I have an Enterprise Miner diagram which does the following: Inputs a dataset -&amp;gt; Partitions into training and validation -&amp;gt; Groups variables using Interactive Grouping -&amp;gt; Creates a credit Scorecard -&amp;gt; Scores up the dataset with the Score node -&amp;gt; Creates a custom report in a SAS Code node.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the last node (SAS Code), I will calculate various statistics, but essentially I need to output a frequency table for grouped variables, using the group labels created by the Interactive Grouping node. The question is how I access those labels.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To illustrate, here's a very simple piece of code that I could use in the SAS Code node:&lt;/P&gt;&lt;PRE&gt;proc freq data=&amp;amp;EM_IMPORT_DATA;
	table GRP_age / norow nocol nopercent nocum missing;
run;&lt;/PRE&gt;&lt;P&gt;The variable 'GRP_age' is created by the Score node using the grouping definitions from Interactive Grouping, and is derived from the input variable 'age'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This creates the following result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;GRP_age Frequency&lt;BR /&gt;--------------------&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 755&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1190&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1302&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1580&lt;BR /&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1100&lt;BR /&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 643&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;...but I would like to see this:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Group Name &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; Frequency&lt;BR /&gt;----------------------------&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;age&amp;lt; 32, _MISSING_ &amp;nbsp; &amp;nbsp;&amp;nbsp; 755&lt;BR /&gt;32&amp;lt;= age&amp;lt; 40 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1190&lt;BR /&gt;40&amp;lt;= age&amp;lt; 47 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1302&lt;BR /&gt;47&amp;lt;= age&amp;lt; 56 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1580&lt;BR /&gt;56&amp;lt;= age&amp;lt; 65 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1100&lt;BR /&gt;65&amp;lt;= age &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 643&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Guessing I need to merge in a table from the IG node. Any ideas what this other table is called (in a way that will work if I connect my SAS Code node to a new Interactive Grouping node)?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Thanks!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Tom.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 04:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Using-interactive-grouping-labels-in-custom-SAS-EM-node/m-p/653501#M8296</guid>
      <dc:creator>tom_evans_79</dc:creator>
      <dc:date>2020-06-05T04:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using interactive grouping labels in custom SAS EM node</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Using-interactive-grouping-labels-in-custom-SAS-EM-node/m-p/706957#M8540</link>
      <description>&lt;P&gt;Here's an answer to my own question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code can be used as part of a SAS Code Node. It accesses the interactive grouping labels that are produced by a preceding interactive grouping node, and creates a format for each of the variables that were grouped. The labels can then be accessed by applying the format to the corresponding GRP_ variable.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Get Interactive Grouping Node ID;
%EM_PATH (nodeid=&amp;amp;em_nodeid. , outds=all_nodes , nodes=PATH);
data ign_node;
	set all_nodes (where=(component="IGN"));
run;
data ign_node;
	set ign_node;
	by component;
	if last.component;
run;
proc sql;
	select nodelabel into :ign_nodeid from ign_node;
quit;

* Create formats from the data table. The _Z is to avoid invalid formats ending in numbers;
proc sql;
create table fmt_input as
	select compress("F_"||substrn(_grp_variable_,5,100)||"_Z") as fmtname,
          _group_ as start, 
          _label_ as label
	from &amp;amp;em_lib..%sysfunc(cats(%CMPRES(&amp;amp;ign_nodeid.),_stats))  a
       left join &amp;amp;em_lib..%sysfunc(cats(%CMPRES(&amp;amp;ign_nodeid.),_varmappings))  b on b._variable_ = a.display_var
    where a.display_var is not null	   
	;
quit;
PROC FORMAT CNTLIN=fmt_input; 


* Test code something like this;
data&amp;nbsp;test;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set&amp;nbsp;&amp;amp;em_import_data. (obs=20);
    label_myvar = put(GRP_myvar,F_myvar_Z.);&amp;nbsp;&amp;nbsp;
run;
proc&amp;nbsp;print&amp;nbsp;data=test;
    var GRP_myvar label_myvar;
run;&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;</description>
      <pubDate>Fri, 18 Dec 2020 15:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Using-interactive-grouping-labels-in-custom-SAS-EM-node/m-p/706957#M8540</guid>
      <dc:creator>tom_evans_79</dc:creator>
      <dc:date>2020-12-18T15:03:02Z</dc:date>
    </item>
  </channel>
</rss>

