<?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: Finding the name of the winning model programaticaly in EM in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292830#M4367</link>
    <description>&lt;P&gt;Awesome thank you I did not know about that table! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2016 19:50:43 GMT</pubDate>
    <dc:creator>Amuresan</dc:creator>
    <dc:date>2016-08-19T19:50:43Z</dc:date>
    <item>
      <title>Finding the name of the winning model programmatically in EM</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292741#M4362</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;Hey all,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;I'm doing some coding in EM and am leveraging some of the background tables sas generates. To this end, I would need to find the name of the current winning model from a model_comparison node.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;I want this code to be plug and playable anywhere (so not linked to the workspace or the id name of any other node)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;For example in order to get the name of the stat explore before it I run the following code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let stat_nm= %substr(&amp;amp;EM_IMPORT_DATA.,%length(&amp;amp;EM_LIB.)+2,%length(&amp;amp;EM_IMPORT_DATA.) - (%length(&amp;amp;EM_LIB.)+1) - 6);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;Since&amp;nbsp;&amp;amp;EM_IMPORT_DATA. resolves to&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;EM_LIB..(predecesor_node_id)_TRAIN. &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;(which I am enforcing has to be a stat node)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;I tried doing something similar using &amp;amp;EM_IMPORT_DATA_EMINFO., which resolves to&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;EM_LIB..(WINNING_MOIDEL_NODE_ID)_EMINFO.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;But for some reason, even though I can see this variable in the macro variable pane ( see below), I get an error that that variable is unitiated when I try to reference it.&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;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4652i2C36555EC64E7AE7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="variable_pane.PNG" title="variable_pane.PNG" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;I also tried using the code noides cmeta_train table which has that information (see code below), this worked at first, but on a subsequent run of the node, this table did not generate and i got an error.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	select 
		model into :model_nm separated by ''
	from &amp;amp;EM_LIB..&amp;amp;EM_NODEID._CMETA_TRAIN
		where Role = 'TARGET';
quit;

%let effect_tbl = &amp;amp;EM_LIB..&amp;amp;model_nm._EFFECTS;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;Below is the set up of my nodes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;Please let me know if there is a good way to find the node id of the model that winds the comparison node, or if I can force the cmeta table to generate.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;P.S. running EM 13.2 on depot 9.04 M2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10.5pt; font-family: 'Helvetica','sans-serif'; color: #333333;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4651i3D2EBD2347EFEA23/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="current_flow.PNG" title="current_flow.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 00:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292741#M4362</guid>
      <dc:creator>Amuresan</dc:creator>
      <dc:date>2016-09-01T00:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the name of the winning model programaticaly in EM</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292811#M4364</link>
      <description>&lt;P&gt;Not sure if this helps, but you can get the name of the node that was selected as "best" from the MdlComp_Emoutfit data set. &amp;nbsp;So you can do something like the following in the SAS Code node after the Model Comparison node:&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 _null_;
  set &amp;amp;em_lib..Mdlcomp_emoutfit;
  where use='Y';
  call symput("bestnode",strip(model));
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;Then the macro variable &lt;STRONG&gt;bestnode&lt;/STRONG&gt; will have the&amp;nbsp;node ID&amp;nbsp;of the modeling node that was chosen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 18:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292811#M4364</guid>
      <dc:creator>WendyCzika</dc:creator>
      <dc:date>2016-08-19T18:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the name of the winning model programaticaly in EM</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292813#M4365</link>
      <description>&lt;P&gt;That helps, but now I would need a way of gettign the name of the mdl_comparison node. I'm invisioning scenarios where there are multiple flows on the same diagram and there are multiple comparison nodes.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292813#M4365</guid>
      <dc:creator>Amuresan</dc:creator>
      <dc:date>2016-08-19T19:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the name of the winning model programaticaly in EM</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292816#M4366</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Retrieve the Node Id of the Model Comparison node preceding the SAS Code node */
data _null_;
   set &amp;amp;em_lib..em_dgraph;
   if TO="&amp;amp;EM_NODEID" then call symput('mcID',strip(FROM));
run;

/*Retrieve the Node ID of the best model */
data _null_;
  set &amp;amp;em_lib..&amp;amp;mcID._emoutfit;
  where use='Y';
  call symput("bestnode",strip(model));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292816#M4366</guid>
      <dc:creator>WendyCzika</dc:creator>
      <dc:date>2016-08-19T19:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the name of the winning model programaticaly in EM</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292830#M4367</link>
      <description>&lt;P&gt;Awesome thank you I did not know about that table! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2016 19:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/292830#M4367</guid>
      <dc:creator>Amuresan</dc:creator>
      <dc:date>2016-08-19T19:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the name of the winning model programaticaly in EM</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/293477#M4383</link>
      <description>I am saving this post  as well. Thanks Wendy. Jason Xin</description>
      <pubDate>Tue, 23 Aug 2016 15:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Finding-the-name-of-the-winning-model-programmatically-in-EM/m-p/293477#M4383</guid>
      <dc:creator>JasonXin</dc:creator>
      <dc:date>2016-08-23T15:53:01Z</dc:date>
    </item>
  </channel>
</rss>

