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 View data prep sheet
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.

Copied!
1 
2PROC CAS;
3 
4SESSION casauto;
5 
6DATA casuser.cars;
7SET sashelp.cars;
8 
9RUN;
10 
11QUIT;
12 

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 Code awaiting community validation
Copied!
1 
2PROC CAS;
3TABLE.attribute / name='CARS' caslib='CASUSER' SET='Origin' attributes={{key='DataSource', value='InternalSystem'}};
4 
5RUN;
6 
7QUIT;
8 
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 Code awaiting community validation
Copied!
1 
2PROC CAS;
3TABLE.attribute / name='CARS' caslib='CASUSER' SET='Details' attributes={{key='Version', value='1.2'}, {key='Description', value='Manufacturer Suggested Retail Price', column='MSRP'}};
4 
5RUN;
6 
7QUIT;
8 
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 Code awaiting community validation
Copied!
1 
2PROC CAS;
3TABLE.attribute / task='UPDATE' name='CARS' caslib='CASUSER' SET='Details' attributes={{key='Version', value='1.3'}};
4 
5RUN;
6 
7QUIT;
8 
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 Code awaiting community validation
Copied!
1 
2PROC CAS;
3TABLE.attribute / task='DROP' name='CARS' caslib='CASUSER' SET='Details' attributes={{key='Description', column='MSRP'}};
4 
5RUN;
6 
7QUIT;
8 
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 Code awaiting community validation
Copied!
1 
2PROC CAS;
3TABLE.attribute / task='EXPORT' name='CARS' caslib='CASUSER' TABLE='CarAttributes';
4 
5RUN;
6TABLE.fetch / TABLE='CarAttributes';
7 
8RUN;
9 
10QUIT;
11 
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?

Associated Scenarios

Use Case
Data Lineage and PII Tagging for Regulatory Compliance

A financial institution needs to track data lineage for its customer analytics table. They must tag the table with its source system, refresh date, and data steward. Additionall...

Use Case
Batch Attribute Assignment for a Model Factory

A data science team runs a 'model factory' process that generates hundreds of individual forecast tables daily. To manage this output, they need an efficient, batch-oriented met...

Use Case
Handling Special Characters, Mixed Types, and Invalid Operations

A research team is annotating experimental data. They need to add attributes with complex free-form text, including special characters. They also need to ensure the system is ro...