BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Amuresan
Fluorite | Level 6

 

Hey all,

 

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.

 

I want this code to be plug and playable anywhere (so not linked to the workspace or the id name of any other node)

 

For example in order to get the name of the stat explore before it I run the following code:

 

%let stat_nm= %substr(&EM_IMPORT_DATA.,%length(&EM_LIB.)+2,%length(&EM_IMPORT_DATA.) - (%length(&EM_LIB.)+1) - 6);

 

Since &EM_IMPORT_DATA. resolves to

&EM_LIB..(predecesor_node_id)_TRAIN. 

 (which I am enforcing has to be a stat node)

 

I tried doing something similar using &EM_IMPORT_DATA_EMINFO., which resolves to 

&EM_LIB..(WINNING_MOIDEL_NODE_ID)_EMINFO.

 

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.

 

 

 

 variable_pane.PNG

 

 

 

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.

 

proc sql;
	select 
		model into :model_nm separated by ''
	from &EM_LIB..&EM_NODEID._CMETA_TRAIN
		where Role = 'TARGET';
quit;

%let effect_tbl = &EM_LIB..&model_nm._EFFECTS;

 

Below is the set up of my nodes.

 

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.

 

P.S. running EM 13.2 on depot 9.04 M2

 

current_flow.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
WendyCzika
SAS Employee

Try this:

 

/*Retrieve the Node Id of the Model Comparison node preceding the SAS Code node */
data _null_;
   set &em_lib..em_dgraph;
   if TO="&EM_NODEID" then call symput('mcID',strip(FROM));
run;

/*Retrieve the Node ID of the best model */
data _null_;
  set &em_lib..&mcID._emoutfit;
  where use='Y';
  call symput("bestnode",strip(model));
run;

View solution in original post

5 REPLIES 5
WendyCzika
SAS Employee

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.  So you can do something like the following in the SAS Code node after the Model Comparison node:

 

 

data _null_;
  set &em_lib..Mdlcomp_emoutfit;
  where use='Y';
  call symput("bestnode",strip(model));
run;

 

 

Then the macro variable bestnode will have the node ID of the modeling node that was chosen.

  

Amuresan
Fluorite | Level 6

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.

WendyCzika
SAS Employee

Try this:

 

/*Retrieve the Node Id of the Model Comparison node preceding the SAS Code node */
data _null_;
   set &em_lib..em_dgraph;
   if TO="&EM_NODEID" then call symput('mcID',strip(FROM));
run;

/*Retrieve the Node ID of the best model */
data _null_;
  set &em_lib..&mcID._emoutfit;
  where use='Y';
  call symput("bestnode",strip(model));
run;
Amuresan
Fluorite | Level 6

Awesome thank you I did not know about that table! 🙂

JasonXin
SAS Employee
I am saving this post as well. Thanks Wendy. Jason Xin

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1683 views
  • 3 likes
  • 3 in conversation