SAS Viya. Kevin D. Smith
action to do that. We are going to use the all=True option to see all of the action sets that are installed on the server rather than only the ones that are currently loaded.
# Run the actionsetinfo action.
In [56]: asinfo = conn.actionsetinfo(all=True)
# Filter the DataFrame to contain only action sets that
# have not been loaded yet.
In [57]: asinfo = asinfo.setinfo[asinfo.setinfo.loaded == 0]
# Create a new DataFrame with only columns between
# actionset and label.
In [58]: asinfo = asinfo.ix[:, 'actionset':'label']
In [59]: asinfo
Out[59]:
Action set information
actionset label
0 access
1 aggregation
2 astore
3 autotune
4 boolRule
5 cardinality
6 clustering
7 decisionTree
… … …
41 svm
42 textMining
43 textParse
44 transpose
45 varReduce
46 casfors Simple forecast service
47 tkcsestst Session Tests
48 cmpcas
59 tkovrd Forecast override
50 qlimreg QLIMREG CAS Action Library
51 panel Panel Data
52 mdchoice MDCHOICE CAS Action Library
53 copula CAS Copula Simulation Action Library
54 optimization Optimization
55 localsearch Local Search Optimization
[56 rows x 2 columns]
Depending on your installation and licensing, the list varies from system to system. One very useful action set that should be automatically available on all systems is the simple action set. This action set contains actions for simple statistics such as summary statistics (max, min, mean, and so on), histograms, correlations, and frequencies. To load an action set, use the loadactionset action:
In [60]: conn.loadactionset('simple')
NOTE: Added action set 'simple'.
Out[60]:
[actionset]
'simple
+ Elapsed: 0.0175s, user: 0.017s, mem: 0.255mb
As you can see, this action returns a CASResults object as described in the previous section. It contains a single key called actionset that contains the name of the action set that was loaded. Typically, you do not need this return value, but it can be used to verify that the action set has been loaded. If you attempt to load an action set that cannot be loaded for some reason (such as incorrect name, no license, or no authorization), the CASResults object is empty.
Now that we have loaded the simple action set, we can get help on it using the usual Python methods.
In [61]: conn.simple?
Type: Simple
String form: <swat.cas.actions.Simple object at 0x7f3cdf7c07f0>
File: swat/cas/actions.py
Docstring:
Analytics
Actions
-------
simple.correlation : Generates a matrix of Pearson product-moment
correlation coefficients
simple.crosstab : Performs one-way or two-way tabulations
simple.distinct : Computes the distinct number of values of the
variables in the variable list
simple.freq : Generates a frequency distribution for one or
more variables
simple.groupby : Builds BY groups in terms of the variable value
combinations given the variables in the variable
list
simple.mdsummary : Calculates multidimensional summaries of numeric
variables
simple.numrows : Shows the number of rows in a Cloud Analytic
Services table
simple.paracoord : Generates a parallel coordinates plot of the
variables in the variable list
simple.regression : Performs a linear regression up to 3rd-order
polynomials
simple.summary : Generates descriptive statistics of numeric
variables such as the sample mean, sample
variance, sample size, sum of squares, and so on
simple.topk : Returns the top-K and bottom-K distinct values of
each variable included in the variable list based
on a user-specified ranking order
Once an action set has been loaded, it cannot be unloaded. The overhead for keeping an action set loaded is minimal, so this issue doesn’t make a significant difference.
That is really all there is to loading action sets. We still do not have data in our system, so we cannot use any of the simple statistics actions yet. Let’s review some final details about options and dealing with errors in the next section, then the following chapter gets into the ways of loading data and using the analytical actions on those data sets.
Details
We have covered the overall workings of connecting to a CAS host, running CAS actions, working with the results of CAS actions, and loading CAS action sets. However, there are some details that we haven’t covered. Although these items aren’t necessary for using SWAT and CAS, they can be quite useful to have in your tool belt.
Getting Help
Even though we have already covered the methods for getting help from CAS, it is an important topic to recap. Every object in the SWAT package uses the standard Python method of surfacing documentation. This includes the help function in Python (for example, help(swat.CAS)), the ? suffix operator in IPython and Jupyter (for example, swat.CAS?), and any other tool that uses Python’s docstrings.
In addition, action sets and actions that are loaded dynamically also support the same Python, IPython, and Jupyter Help system hooks (for example, conn.summary?).
Keep in mind that tab completion on the CAS objects and other objects in the SWAT package can be a quick reminder of the attributes and methods of that object.
These Help system hooks should be sufficient to help you get information about any objects in the SWAT package, CAS action sets, and CAS actions and their parameters. If more detailed information is needed,