table attribute

Handling Special Characters, Mixed Types, and Invalid Operations

Scénario de test & Cas d'usage

Business Context

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 robust and provides clear feedback when a user attempts an invalid operation, such as dropping an attribute that doesn't exist or updating an attribute on a non-existent column.
About the Set : table

Loading, saving, and managing in-memory tables.

Discover all actions of table
Data Preparation

Create a simple table representing experimental results.

Copied!
1DATA casuser.lab_results;
2 INPUT SubjectID $ Measurement;
3 DATALINES;
4SUBJ-01 9.5
5SUBJ-02 11.2
6SUBJ-03 8.9
7;
8RUN;

Étapes de réalisation

1
Load the lab results data into CAS.
Copied!
1PROC CAS;
2 TABLE.loadTable /
3 caslib='CASUSER'
4 path='lab_results.sashdat'
5 casOut={name='LAB_RESULTS', replace=true};
6RUN;
2
Add an attribute with a complex string value containing special characters (quotes, semicolons).
Copied!
1PROC CAS;
2 TABLE.attribute /
3 task='ADD'
4 name='LAB_RESULTS' caslib='CASUSER' SET='Annotations'
5 attributes={{key='ReviewNote', value='Data looks good; verified by O''Malley. Final check pending.'}};
6RUN;
3
Attempt to drop a non-existent attribute. This should not produce an error.
Copied!
1PROC CAS;
2 TABLE.attribute /
3 task='DROP'
4 name='LAB_RESULTS' caslib='CASUSER' SET='Annotations'
5 attributes={{key='NonExistentKey'}};
6RUN;
4
Attempt to update an attribute on a non-existent column. This is expected to fail and produce an error in the log.
Copied!
1PROC CAS;
2 TABLE.attribute /
3 task='UPDATE'
4 name='LAB_RESULTS' caslib='CASUSER' SET='Annotations'
5 attributes={{key='ReviewNote', value='New Value', column='NonExistentColumn'}};
6RUN;
5
Successfully drop the complex string attribute added in step 2.
Copied!
1PROC CAS;
2 TABLE.attribute /
3 task='DROP'
4 name='LAB_RESULTS' caslib='CASUSER' SET='Annotations'
5 attributes={{key='ReviewNote'}};
6RUN;
7QUIT;

Expected Result


Step 2 succeeds. Step 3 completes without error, but the log should indicate that the attribute to be dropped was not found. Step 4 fails with a clear error message in the SAS log stating the column 'NonExistentColumn' does not exist. Step 5 succeeds, removing the 'ReviewNote' attribute. This confirms the action's robustness in handling both valid and invalid user operations.