BookmarkSubscribeRSS Feed

Exporting pluggable modeling node results tables to SAS® Visual Analytics and SAS® Studio

Started ‎07-09-2019 by
Modified ‎07-09-2019 by
Views 4,267

SAS® Visual Forecasting 8.4 has an automated modeling application, called Model Studio, that enables you to apply different modeling strategies on your data. A popular question that is often asked when working with Model Studio is how to view and export the tables that are created in pluggable modeling nodes. A successful run of each modeling node creates several tables, such as OUTFOR, OUTMODELINFO, OUTSELECT, and so on, as shown in the following graphic. You can see which tables are created by right-clicking the node and selecting Results. For more information about viewing results, see SAS® Visual Forecasting 8.4: User’s Guide.

 

forecasting 1.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

You can view these tables and export them to SAS Visual Analytics or SAS Studio for further processing.

 

You may want to generate and view other table besides those listed by default in Model Studio. For example, the current release of SAS Visual Forecasting does not create a table that records the parameter estimates of the champion model for each BY group. This blog post explains how to create this table, called OUTEST, and how to export it to SAS Visual Analytics and SAS Studio.

 

This article uses the Auto-forecasting modeling node to illustrate this process, but the process works for every pluggable modeling node. The Auto-forecasting node uses the TSMODEL procedure and the Automatic Time Series Modeling (ATSM) package to automatically fit the best model and generate forecasts from the selected model families. To learn more about the ATSM package, see SAS Visual Forecasting 8.4: Time Series Packages.

 

Pluggable modeling nodes contain a code editor that enables you to customize their contents. The code editor option for each modeling node in a pipeline can be found in the right panel view. Click Open to see the content of the node.

 

forecasting 2.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

To create a table that keeps the parameter estimates of the best model for each BY group, modify the auto-forecasting code as shown in the following steps:

  • Define a macro variable that keeps the name of the OUTEST table: %let vf_outest = &vf_tableOutPrefix..myoutest;
  • Declare an outest object:

forecasting 3.jpg

 

 

 

 

 

 

 

  • Collect the parameter estimates from the forecast object:

forecasting 4.png

 

 

 

 

  • Modify the OUTOBJ option in a run of PROC TSMODEL to link a CAS table to the defined outest object:

forecasting 5.png

 

 

 

 

 

 

 

 

The OUTEST table is created by the PROC TSMODEL run, and its name is recorded in the vf_outest macro variable. This table is available only at this CAS session and is removed if not promoted. Therefore, this table needs to be saved on a disk or promoted to a CAS library (such as the CASUSER library) in order for you to access it in SAS Visual Analytics or SAS Studio. There are multiple ways to save or promote the table, two of which are presented below. You can copy either of the following sections of example code to the end of auto-forecasting code and save the code. In these sections of example code, you can replace vf_outest macro variable with any other table name you want to promote.

 

In the first approach, you export the table to the CASUSER library by using the fedSql.execDirect action, which saves the table on disk and promotes the exported table:

%let exportCaslib = CASUSER;
%let exporttbl = &vf_outest;

proc cas;
	*drop existing exported table;
	table.dropTable /
		caslib="&exportCaslib"
		name="&exporttbl"
		quiet=true;
	*export table;
	fedSql.execDirect /
		query="create table ""&exportCaslib"".""&exporttbl"" {options replace=true} as select * from ""&vf_caslibOut"".""&exporttbl""";
	*save exported table;
	table.save /
		table={caslib="&exportCaslib",name="&exporttbl"}
		caslib="&exportCaslib"
		name="&exporttbl..sashdat"
		replace=true
		compress=true;
	*promote exported table;
	table.promote /
		caslib="&exportCaslib"
		targetLib="&exportCaslib"
		name="&exporttbl";
run;

In the second approach, you save the table in the CASUSER directory as a sashdat file, load it into memory, and then promote it:

%let exportCaslib = CASUSER;
%let exporttbl = &vf_outest;

proc cas;
	*drop existing table;
	table.dropTable /
		caslib="&exportCaslib"
		name="&exporttbl"
		quiet=true;
	*save table to disk;
	table.save /
		table={caslib="&vf_caslibOut",name= "&exporttbl"}
		caslib="&exportCaslib"
		name="&exporttbl..sashdat"
		replace=true
		compress=true;
	*load table to memory;
	table.loadTable / 
	path="&exporttbl..sashdat"
	casout={name="&exporttbl"};
	*promote the table;
	table.promote /
		caslib="&exportCaslib"
		targetLib="&exportCaslib"
		name="&exporttbl";
run;

Both of these examples use the tables action set. For more information about the tables action set, see SAS Viya System Programming Guide. The extension of the saved files on disk is sashdat, which identifies it as a SAS high-performance data file. This extension is the default type for SAS Viya.

 

Accessing the table from SAS Visual Analytics

Click the forecasting icon.png icon on the top left corner of the page and select Explore and Visualize Data. You will be redirected to SAS Visual Analytics.

 

forecasting 6.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After SAS Visual Analytics opens, you will see the following welcome window:

 

forecasting 7.png

 

 

 

 

 

 

 

 

 

 

 

 

Click Data to navigate to the Data Source tab, and go to the CASUSER folder, which contains the CAS table and sashdat file.  Select the loaded table and start your analysis:

 

forecasting 8.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Accessing the table from SAS Studio

You can also access the table through SAS Studio by creating a session. See the following code, which creates a CAS session (named mycas) and uses the CASUTIL procedure to list the tables in the library:

 

 

cas mycas;

proc casutil;
	list tables;
run;

 

 

forecasting 9.png

 

 

 

 

 

Conclusions

This blog post shows how you can view tables that are created in pluggable modeling nodes and export them to SAS Visual Analytics and SAS Studio. It also explains how you can create a model parameters table, called OUTEST, by modifying the pluggable modeling node code.

 

Acknowledgment

I would like to thank Phil Helmkamp for his insightful instructions.

 

References

Shannon, David. 2018. “Come On, Baby, Light My SAS® Viya®: Programming for CAS.” Proceedings of the SAS Global Forum 2018 Conference. Cary, NC: SAS Institute Inc. Available https://support.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2018/2622-2018.pdf

Comments

Hi,

It's really useful article. Thank you so much. 

But I want to ask something. If I use stacked model node to forecast, how can I export and promote the outfor table? Stacked model is not a pluggable model.

Version history
Last update:
‎07-09-2019 12:06 PM
Updated by:
Contributors

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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