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

Hi,

 

We're converting material from Enterprise Miner over to Viya Model Studio. We have a custom SAS code node that reads information from a preceding Interactive Grouping node, to get the group labels for the groups created by the IG node.

 

To get this info in Miner, we use a table called something like ign_stats. I know this exists at least temporarily in Viya but I can't access it in code. Any ideas how I might find it?

 

In Miner we used the code below.

 

Many thanks,

 

Tom.

 

 

 

 

%EM_PATH (nodeid=&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;
proc print data=&em_lib..%sysfunc(cats(%CMPRES(&ign_nodeid.),_stats));
run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
WendyCzika
SAS Employee
/* SAS code */
/* Retrieve the id of the last Interactive Grouping node */
%let cs_guid=;
data _null_;
   set &dm_predecessors end=eof;
   where component='cs_ign';
   if eof then call symputx('cs_guid', guid);
run;
data _null_;
   folder = dcreate(strip(symget('cs_guid')), "&dmcas_workpath"); /* Create a folder to put all the files registered */
run;

/* Fetch all registered files under that node */
%dmcas_fetchRegistered(&cs_guid, &dmcas_workpath.&dm_dsep.&cs_guid);

/* Fetch from the dmcas_report table on the data sets */
libname cslib "&dmcas_workpath.&dm_dsep.&cs_guid";
data work.reportTables; 
   set cslib.dmcas_report;
    where upcase(name) in('DATASET', 'FILE');
run;
proc sort data=work.reportTables NODUPKEY;
   by VALUE;
run;
/* view the registered files for the node */
proc print data=work.reportTables;
run;

/* this is ign_stats data set */
proc print data=cslib.ign_stats; 
run;

libname cslib;

Hi Tom - this code might be a bit of overkill since you know the data set that you want to access, but this should get you what you want I think.

Hope that helps!

 

View solution in original post

3 REPLIES 3
WendyCzika
SAS Employee
/* SAS code */
/* Retrieve the id of the last Interactive Grouping node */
%let cs_guid=;
data _null_;
   set &dm_predecessors end=eof;
   where component='cs_ign';
   if eof then call symputx('cs_guid', guid);
run;
data _null_;
   folder = dcreate(strip(symget('cs_guid')), "&dmcas_workpath"); /* Create a folder to put all the files registered */
run;

/* Fetch all registered files under that node */
%dmcas_fetchRegistered(&cs_guid, &dmcas_workpath.&dm_dsep.&cs_guid);

/* Fetch from the dmcas_report table on the data sets */
libname cslib "&dmcas_workpath.&dm_dsep.&cs_guid";
data work.reportTables; 
   set cslib.dmcas_report;
    where upcase(name) in('DATASET', 'FILE');
run;
proc sort data=work.reportTables NODUPKEY;
   by VALUE;
run;
/* view the registered files for the node */
proc print data=work.reportTables;
run;

/* this is ign_stats data set */
proc print data=cslib.ign_stats; 
run;

libname cslib;

Hi Tom - this code might be a bit of overkill since you know the data set that you want to access, but this should get you what you want I think.

Hope that helps!

 

WendyCzika
SAS Employee

Since this question has come up before, this prompted me to add some example code to our GitHub repo: https://github.com/sassoftware/sas-viya-dmml-pipelines/tree/master/sas_code_node/access_data_from_pr...

 

Tom, you can use the use_data_from_predecessor.sas one since you know the name of your data set is ign_stats, so just substitute that for xyz.

tom_evans_79
Fluorite | Level 6
Super - thanks very much. It's that %dmcas_fetchRegistered macro that's the magic part.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 1582 views
  • 2 likes
  • 2 in conversation