table attribute

Batch Attribute Assignment for a Model Factory

Scénario de test & Cas d'usage

Business Context

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 method to tag each new table with its corresponding model metadata (Model ID, Algorithm, Target Variable) from a central control table.
About the Set : table

Loading, saving, and managing in-memory tables.

Discover all actions of table
Data Preparation

Create a control table containing the attributes for multiple forecast tables. Then, create several empty forecast tables to simulate the output of a model factory.

Copied!
1DATA casuser.model_metadata;
2 LENGTH _tableName_ $ 32 _caslib_ $ 8 _attrName_ $ 20 _attrValue_ $ 50;
3 INFILE DATALINES dsd;
4 INPUT _tableName_ $ _caslib_ $ _attrName_ $ _attrValue_ $;
5 DATALINES;
6FORECAST_STORE101, CASUSER, ModelID, F-S101-20251126
7FORECAST_STORE101, CASUSER, Algorithm, ARIMA
8FORECAST_STORE101, CASUSER, Target, Sales
9FORECAST_STORE205, CASUSER, ModelID, F-S205-20251126
10FORECAST_STORE205, CASUSER, Algorithm, ESM
11FORECAST_STORE205, CASUSER, Target, Inventory
12FORECAST_STORE330, CASUSER, ModelID, F-S330-20251126
13FORECAST_STORE330, CASUSER, Algorithm, ARIMA
14FORECAST_STORE330, CASUSER, Target, Sales
15;
16RUN;
17 
18DATA casuser.FORECAST_STORE101; x=1; RUN;
19DATA casuser.FORECAST_STORE205; x=1; RUN;
20DATA casuser.FORECAST_STORE330; x=1; RUN;

Étapes de réalisation

1
Load the metadata control table and the empty forecast tables into CAS.
Copied!
1PROC CAS;
2 TABLE.loadTable / caslib='CASUSER' path='model_metadata.sashdat' casOut={name='MODEL_METADATA', replace=true};
3 TABLE.loadTable / caslib='CASUSER' path='FORECAST_STORE101.sashdat' casOut={name='FORECAST_STORE101', replace=true};
4 TABLE.loadTable / caslib='CASUSER' path='FORECAST_STORE205.sashdat' casOut={name='FORECAST_STORE205', replace=true};
5 TABLE.loadTable / caslib='CASUSER' path='FORECAST_STORE330.sashdat' casOut={name='FORECAST_STORE330', replace=true};
6RUN;
2
Use a single 'attribute' action call with the 'table' parameter to add attributes to all forecast tables from the metadata control table.
Copied!
1PROC CAS;
2 TABLE.attribute /
3 task='ADD'
4 caslib='CASUSER'
5 TABLE='MODEL_METADATA';
6RUN;
3
Verify the attributes for one of the tables by exporting them.
Copied!
1PROC CAS;
2 TABLE.attribute /
3 task='EXPORT'
4 name='FORECAST_STORE205'
5 caslib='CASUSER'
6 TABLE='VERIFY_ATTRIBUTES';
7 
8 TABLE.fetch / TABLE='VERIFY_ATTRIBUTES';
9RUN;
10QUIT;

Expected Result


The action should successfully add attributes to all three forecast tables in a single call. The final fetch on 'VERIFY_ATTRIBUTES' should display the three attributes ('ModelID', 'Algorithm', 'Target') for the 'FORECAST_STORE205' table, confirming the batch operation was successful.