?> attribute - WeAreCAS
table

attribute

Description

The `attribute` action manages extended attributes for in-memory tables in CAS. Extended attributes are user-defined metadata, stored as key-value pairs, that can be associated with a table or specific columns within a table. This action allows for adding, updating, dropping, and exporting these attributes, providing a flexible way to enrich data with additional context or information without altering the data itself.

table.attribute <result=results> <status=rc> / attributes={{column="string", key="string", value="string" | 64-bit-integer | integer | double | binary-large-object}, {...}}, caslib="string", name="string", set="string", table="string", task="ADD" | "CONVERT" | "DROP" | "EXPORT" | "UPDATE", xml="string", xmlPath="string";
Settings
ParameterDescription
attributesSpecifies the extended attributes. You must specify the set parameter if you specify this parameter. It can be a list of attribute definitions, each with a key and a value, and optionally a column name.
caslibSpecifies the target caslib for the extended attributes table.
nameSpecifies the name for the in-memory table to which the attributes are being applied.
setSpecifies the name for the extended attributes set.
tableSpecifies the name of an existing extended attributes table to use with an ADD, UPDATE, or CONVERT task. For CONVERT, this parameter names the table to use for storing the extended attributes.
taskSpecifies the task to perform. Can be ADD, CONVERT, DROP, EXPORT, or UPDATE. The default is ADD.
xmlSpecifies the extended attributes as an XML document string.
xmlPathSpecifies the path to a file that includes the extended attributes as an XML document.
Data Preparation
Data Creation

This code creates a simple in-memory table named 'CARS' in the 'CASUSER' caslib. This table will be used in the examples to demonstrate how to manage extended attributes.

proc cas; session casauto; data casuser.cars; set sashelp.cars; run; quit;

Examples

This example adds a single extended attribute to the 'CARS' table. The attribute key is 'DataSource' and its value is 'InternalSystem'.

SAS® / CAS Code
Copied!
1PROC CAS; TABLE.attribute / name='CARS' caslib='CASUSER' SET='Origin' attributes={{key='DataSource', value='InternalSystem'}}; RUN; QUIT;
Result :
The action adds the specified attribute to the 'CARS' table. A confirmation message indicating the success of the operation is returned.

This example demonstrates adding multiple attributes. One attribute ('Version') is for the entire 'CARS' table, and another ('Description') is specific to the 'MSRP' column.

SAS® / CAS Code
Copied!
1PROC CAS; TABLE.attribute / name='CARS' caslib='CASUSER' SET='Details' attributes={{key='Version', value='1.2'}, {key='Description', value='Manufacturer Suggested Retail Price', column='MSRP'}}; RUN; QUIT;
Result :
Two attributes are added. The result will show the successful addition of both the table-level and column-level attributes.

This example updates the value of the 'Version' attribute (from the previous example) from '1.2' to '1.3'.

SAS® / CAS Code
Copied!
1PROC CAS; TABLE.attribute / task='UPDATE' name='CARS' caslib='CASUSER' SET='Details' attributes={{key='Version', value='1.3'}}; RUN; QUIT;
Result :
The value of the 'Version' attribute is updated. The action's log will confirm the update.

This example removes the 'Description' attribute that was previously added to the 'MSRP' column.

SAS® / CAS Code
Copied!
1PROC CAS; TABLE.attribute / task='DROP' name='CARS' caslib='CASUSER' SET='Details' attributes={{key='Description', column='MSRP'}}; RUN; QUIT;
Result :
The specified column attribute is dropped. The result indicates the successful removal.

This example exports all extended attributes associated with the 'CARS' table into a new CAS table named 'CarAttributes'.

SAS® / CAS Code
Copied!
1PROC CAS; TABLE.attribute / task='EXPORT' name='CARS' caslib='CASUSER' TABLE='CarAttributes'; RUN; TABLE.fetch / TABLE='CarAttributes'; RUN; QUIT;
Result :
A new table named 'CarAttributes' is created in the 'CASUSER' caslib containing all the extended attributes of the 'CARS' table. The fetch action then displays the content of this new attributes table.

FAQ

What is the primary purpose of the `attribute` action in the Table action set?
What are the different tasks that the `attribute` action can perform?
How can you specify the attributes to be managed?
What is the difference between the `name` and `table` parameters?
Can an attribute be applied to a specific column, and if so, how?