How 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?
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
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.