BookmarkSubscribeRSS Feed

Asked & Answered: How can I pass data from a SAS Code node into the next node in Model Studio?

Started ‎02-06-2019 by
Modified ‎02-22-2019 by
Views 2,191

Question

97403_banner_Asked&Answered_aqua.pngHow can I pass data from a SAS Code node into the next node in Model Studio?

 

For example:

I want to run a standard proc (e.g. proc MI for multilevel imputation) in a pipeline and want the next node to use the imputed data:

This is my code in the code node:

 

/* SAS code */
cas;
caslib _ALL_ assign;

proc MI data=&dm_data;
      mcmc impute=monotone;
      var dp1_climate_index2 dp1_costoflivingindex dp1_crimeindex;
run;

 

How to pass the results to the next Variable Clustering node?

AA1 - Pass data in code node.png

Answer

To pass transformed data from a SAS Code node to the following node, you will need to provide the score code (from the proc or by explicitly creating it) in the &dm_file_scorecode macro variable. This macro variable is a filename in the node’s working directory that contains the score code.

 

For example, when building a model, you could use the code statement within the procedure call, like this:

 

code file=&dm_file_scorecode;

For some procs you might need to add more options to the code statement.

 

If the proc you are running does not generate score code (such as proc MI in the question) then the only way to pass data along is to write additional code after running the proc that appends to the score code for the node. For example, here is how you can add calculated columns to the output data table:

 

/* SAS code */
data _null_;
  file "&dm_file_scorecode" mod;
  put 'if mortdue > value then underwater = 1; else underwater = 0;';
  put 'length mortpaid 8; mortpaid = value-mortdue;';
run;

 

For more examples using the SAS Code node, check out our GitHub repo  - it has great examples generating score code from procs, data step, and also generating graphical output

Version history
Last update:
‎02-22-2019 01:11 PM
Updated by:
Contributors

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!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags