Читать книгу SAS Viya - Kevin D. Smith - Страница 22

Scalar Parameter to Dictionary Conversion

Оглавление

Many times when using an action parameter that requires a dictionary as an argument, you use only the first key in the dictionary to specify the parameter. For example, the history action takes a parameter called casout. This parameter specifies an output table to put the history information into. The specification for this parameter follows: (You can use conn.history? in IPython to see the parameter definition.)

casout : dict or CASTable, optional

specifies the settings for saving the action history to an

output table.

casout.name : string or CASTable, optional

specifies the name to associate with the table.

casout.caslib : string, optional

specifies the name of the caslib to use.

casout.timestamp : string, optional

specifies the timestamp to apply to the table. Specify

the value in the form that is appropriate for your

session locale.

casout.compress : boolean, optional

when set to True, data compression is applied to the table.

Default: False

casout.replace : boolean, optional

specifies whether to overwrite an existing table with the same

name.

Default: False

... truncated ...

The first key in the casout parameter is name and indicates the name of the CAS table to create. The complete way of specifying this parameter with only the name key follows:

In [27]: out = conn.history(casout=dict(name='hist'))

This is such a common idiom that the server enables you to specify dictionary values with only the first specified key given (for example, name), just using the value of that key. That is a mouthful, but it is easier than it sounds. It just means that rather than having to use the dict to create a nested dictionary, you could simply do the following:

In [28]: out = conn.history(casout='hist')

Of course, if you need to use any other keys in the casout parameter, you must use the dict form. This conversion of a scalar value to a dictionary value is common when specifying input tables and variable lists of tables, which we see later on.

Now that we have spent some time on the input side of CAS actions, let’s look at the output side.

SAS Viya

Подняться наверх