BookmarkSubscribeRSS Feed

How to use the CAS-tables, that Model Studio creates, elsewhere (in other SAS-apps)?

Started ‎07-08-2023 by
Modified ‎07-09-2023 by
Views 836

In Enterprise Miner (the predecessor of Model Studio) it was very easy to access all datasets and other files created by the different nodes in the flow (or pipeline). This article deals with how-to-do-the-same in Model Studio!

 

Note: Enterprise Miner is SAS 9.x technology and Model Studio is a browser-based app in SAS VIYA 3.x and 4.
Model Studio is not a product that you license. Model Studio is simply the front-end / visual interface to:

  • VDMML (Visual Data Mining and Machine Learning),
  • VF (Visual Forecasting) and
  • VTA (Visual Text Analytics)

Model Studio can be accessed by choosing "Build Models" through the hamburger icon (Applications menu -- "Analytics Life Cycle" category) at the top left.

 

Just as a reminder – how did it work in Enterprise Miner (accessing created data sets in the Enhanced Editor outside EM)?
In Enterprise Miner you have to search, in the file system, for the folder that bears the name of your project (directory path is also listed in the "property panel" of your project in EM). That project folder has two sub-folders that contain datasets, namely:

  • DataSources
  • Workspaces

In the Workspaces folder you will find one more subfolder per diagram (EMWS1, EMWS2, ...). In those diagram-subfolders you will find one more subfolder per node in your diagram. But you hardly need those node-subfolders. All datasets that may interest you are in EMWSx. The datasets all have a prefix that refers to the node where they were generated. The dataset name is always built according to a specific "protocol" and therefore predictable.

 

How does that work in Model Studio?

Suppose you want to use Model Studio tables in SAS Studio or in Visual Analytics.

That's simple but you have to know of course 😉.

 

The most important table in Model Studio is the ABT (Analytical Base Table). That's the input data source. That table is the subject of the very first node in the pipeline, namely the Data node.

That ABT actually travels through the pipeline and is undergoing all kinds of transformations in the meantime. If you open the results panel of a node on the go and you go to the "Output Data" tab, you can view the ABT in the state it is in at that point. You can view / browse the table and also upload it in Visual Analytics. However, there are of course countless other tables created by each node (e.g., for a node where a predictive model is built, ... the parameter estimates table and goodness-of-fit statistics table) and many of them are not offered to you in the "Output Data" tab. So, ... how to work with these?

 

A first (not so interesting) way is to go to the results panel again, but now the "Summary" tab , "Node" tab or "Assessment" tab. In it you will find all objects that contain reported data and the underlying data table can always be downloaded. Each object has a download button at the top right and if you click on that button you can use the :

  • Raw data     or 
  • Formatted data

for download.

Anyway, that is not very practical because that data ends up in *.csv format in the Downloads folder on your desktop and from there you have to upload it again and read / import it into a SAS dataset in SAS Studio to be able to use it.

 

An easier way is to take direct access to the main CAS library that your Model Studio session and project uses. The name of this CASLIB is always built according to the same principle. Namely:

Analytics_Project_URI
(where URI is the Uniform Resource Identifier that each SAS Viya object in the SAS Content folder holds for unique identification).

 

In the program below I give myself access, in SAS Studio, to the CASLIB of the project
with URI = 2eca95d3-3278-451e-990f-db0b92c47210 .
I simply copied that URI from the Details panel in SAS Drive.
( Click the Model Studio project in SAS Drive, and then go to Details > More > URI .)

I want to access the node_flow table and for convenience 

  • I first save / duplicate it in my personal casuser folder using the *.sashdat memory format,
  • then I load it back into the CAS-memory to get started.
cas mySession sessopts=(caslib=casuser timeout=1800 locale="en_US" metrics=TRUE);
caslib _ALL_ assign;
options msglevel=i;

proc casutil incaslib="Analytics_Project_2eca95d3-3278-451e-990f-db0b92c47210";
   list tables;
   list files;
run;

/* Save Table to CASUSER caslib                        */
/* Table name was copy/pasted from PROC CASUTIL output */
proc cas;
            table.save /
            table={  caslib="Analytics_Project_2eca95d3-3278-451e-990f-db0b92c47210"
                   ,   name="NODE_FLOW_1E5478BB-8395-4948-9061-0A2C5E29BE30"},
            caslib  = "casuser",
            name    = "node_flow_out.sashdat",
            replace = TRUE;
run; QUIT;

/* Load Table in Memory */
proc cas;
   table.loadTable /           
      path = "node_flow_out.sashdat",
	caslib = "casuser",
     casout={name="node_flow_out_to_use",caslib="casuser",replace=TRUE};
run; QUIT;

libname mycas cas caslib=casuser sessref=mySession;
/* end of program */

 

There is one more point that deserves attention.
Suppose you create your own tables in a SAS code node. How do you get access there?
That's easy too, but again ... you have to know of course. 😉

 

Here's a piece of code you can use as an example. It is important that you promote the table because otherwise it is only known in the CAS session of your Model Studio project. In other words ... when you create a table in a SAS Code node in Model Studio it will be in local scope and only exist in that session. In order to be able to see it in another session you would need to promote it (from session-scope to global-scope).
For example:

/* SAS code */
libname SBXKOENK CAS CASLIB="&dm_data_caslib";
PROC DATASETS library=SBXKOENK NoList NoDetails memtype=DATA;
	delete MyCopy; run;
QUIT;
data SBXKOENK.MyCopy(/*replace=YES*/ promote=YES);
	set SBXKOENK.&dm_memnamenlit.;
run;
/* end of program */

 

Someone using the SAS code node may also know the autocall macros that start with the prefix "%dmcas_". The most popular is without any doubt : %dmcas_report.

You could also consider using the %dmcas_copyCasTable macro and immediately saving the dataset to your casuser.

Like done here :

/* Save astore to another CAS lib */
%dmcas_copyCasTable(&dm_output_caslib, &forest_astore, casuser, &forest_astore, true);

 

Interesting links:

Model Studio / SAS® Viya®: Machine Learning | LTS 2023.03
Machine Learning User's Guide

Good luck with your analyses!

Comments

Thanks for providing this wealth of information, @sbxkoenk. I keep getting told that my company will have SAS Viya and Model Studio "in a few months" and I'm sure this information will come in handy then.  I have bookmarked your article.

Version history
Last update:
‎07-09-2023 11:00 AM
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