?>
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.
| Parameter | Description |
|---|---|
| attributes | Specifies 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. |
| caslib | Specifies the target caslib for the extended attributes table. |
| name | Specifies the name for the in-memory table to which the attributes are being applied. |
| set | Specifies the name for the extended attributes set. |
| table | Specifies 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. |
| task | Specifies the task to perform. Can be ADD, CONVERT, DROP, EXPORT, or UPDATE. The default is ADD. |
| xml | Specifies the extended attributes as an XML document string. |
| xmlPath | Specifies the path to a file that includes the extended attributes as an XML document. |
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;
This example adds a single extended attribute to the 'CARS' table. The attribute key is 'DataSource' and its value is 'InternalSystem'.
| 1 | PROC CAS; TABLE.attribute / name='CARS' caslib='CASUSER' SET='Origin' attributes={{key='DataSource', value='InternalSystem'}}; RUN; QUIT; |
This example demonstrates adding multiple attributes. One attribute ('Version') is for the entire 'CARS' table, and another ('Description') is specific to the 'MSRP' column.
| 1 | PROC 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; |
This example updates the value of the 'Version' attribute (from the previous example) from '1.2' to '1.3'.
| 1 | PROC CAS; TABLE.attribute / task='UPDATE' name='CARS' caslib='CASUSER' SET='Details' attributes={{key='Version', value='1.3'}}; RUN; QUIT; |
This example removes the 'Description' attribute that was previously added to the 'MSRP' column.
| 1 | PROC CAS; TABLE.attribute / task='DROP' name='CARS' caslib='CASUSER' SET='Details' attributes={{key='Description', column='MSRP'}}; RUN; QUIT; |
This example exports all extended attributes associated with the 'CARS' table into a new CAS table named 'CarAttributes'.
| 1 | PROC CAS; TABLE.attribute / task='EXPORT' name='CARS' caslib='CASUSER' TABLE='CarAttributes'; RUN; TABLE.fetch / TABLE='CarAttributes'; RUN; QUIT; |