builtins

actionSetFromTable

L'essentiel
At a glance
Streamlining the distribution of user-defined logic across different SAS Viya sessions is the primary function of the actionSetFromTable command. Acting as the operational inverse to the save process, this tool allows developers to retrieve serialized action definitions from storage and instantly reactivate them as executable code in memory. This capability is vital for maintaining a consistent library of reusable analytics tools across the enterprise. The Q&A section below addresses common implementation details, guiding you through the steps to successfully reload these custom assets and integrate them into your daily workflows.

Description

Restores a user-defined action set from a saved table. This is useful for sharing custom action sets or for persisting them across CAS sessions. You first need to save an action set using the `actionSetToTable` action.

builtins.actionSetFromTable <result=results> <status=rc> / name="string", table={caslib="string", computedOnDemand=TRUE | FALSE, computedVars={{...}}, computedVarsProgram="string", dataSourceOptions={key-1=any-list-or-data-type-1, ...}, groupBy={{...}}, groupByMode="NOSORT" | "REDISTRIBUTE", importOptions={fileType="ANY" | "AUDIO" | "AUTO" | "BASESAS" | "CSV" | "DELIMITED" | "DOCUMENT" | "DTA" | "ESP" | "EXCEL" | "FMT" | "HDAT" | "IMAGE" | "JMP" | "LASR" | "PARQUET" | "SOUND" | "SPSS" | "VIDEO" | "XLS", ...}, name="table-name", orderBy={{...}}, singlePass=TRUE | FALSE, vars={{...}}, where="where-expression", whereTable={...}};
Settings
ParameterDescription
name Specifies the name for the user-defined action set to be restored.
table Specifies the in-memory table from which to restore the action set. This table must have been created previously using the `actionSetToTable` action.
Data Preparation View data prep sheet
Creating and Saving a Sample Action Set

First, we need to define a simple action set and then save it to a CAS table. This table will then be used as the source to restore the action set. We'll define an action set named 'myCustomActionSet' with a simple 'hello' action, and save it to the 'myActionSetTable' table in the 'CASUSER' caslib.

Copied!
1PROC CAS;
2 BUILTINS.defineActionSet /
3 name='myCustomActionSet',
4 actions={
5 {name='hello', definition={
6 parms={
7 {name='name', type='string', description='Name to say hello to'}
8 },
9 code="print('Hello, ' || name)"
10 }}
11 };
12 RUN;
13 BUILTINS.actionSetToTable /
14 actionSet='myCustomActionSet',
15 TABLE={name='myActionSetTable', caslib='CASUSER', replace=true};
16 RUN;
17QUIT;

Examples

This example demonstrates the basic use of the `actionSetFromTable` action. It restores the 'myCustomActionSet' action set from the 'myActionSetTable' table that was previously saved. The action set is restored with its original name.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3BUILTINS.actionSetFromTable / TABLE={name='myActionSetTable', caslib='CASUSER'};
4 
5RUN;
6 
7QUIT;
8 
Result :
The 'myCustomActionSet' action set is successfully restored and loaded into the current CAS session. You can verify its presence using the `actionSetInfo` action.

This example shows how to restore a user-defined action set under a new name ('restoredSet') and then immediately verify its successful restoration by calling the `actionSetInfo` action. This is a common pattern to ensure the action set is ready for use and to avoid name conflicts.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3BUILTINS.actionSetFromTable / TABLE={name='myActionSetTable', caslib='CASUSER'} name='restoredSet';
4 
5RUN;
6BUILTINS.actionSetInfo / actionSet='restoredSet';
7 
8RUN;
9 
10QUIT;
11 
Result :
The action set is restored with the new name 'restoredSet'. The subsequent call to `actionSetInfo` will display information about the 'restoredSet' action set, including its name and the actions it contains (in this case, the 'hello' action), confirming that the restoration was successful.

FAQ

What is the purpose of the actionSetFromTable action in SAS Viya?
What is the 'name' parameter used for in the actionSetFromTable action?
What does the 'table' parameter signify in the actionSetFromTable action?

Associated Scenarios

Use Case
Standard Reload of a Custom Operations Toolkit

An operations team has developed a standard set of utility actions (e.g., for custom logging, data quality checks) and saved it. A new analyst in a different CAS session needs t...

Use Case
Development: Loading a New Version of an Action Set as an Alias

A data science team is developing a new version of a scoring algorithm. They need to load the new version ('scoringModel_v2') from the same saved table as the original ('scoring...

Use Case
Edge Case: Recovery After Attempting to Load from a Non-Existent Table

An automated script attempts to load a user-defined action set. The script must be robust enough to handle cases where the source table does not exist (e.g., it was not created ...