table copyTable

Standard: Snapshot for Marketing Analysis with Computed Metrics

Scénario de test & Cas d'usage

Business Context

The marketing department needs a static snapshot of active high-value customers to run a targeted email campaign. The source table is live and constantly updating. They need to extract customers who spent more than $500, calculate a 'Loyalty_Score' on the fly based on their tenure, and save this to a separate table to avoid impacting the operational system.
About the Set : table

Loading, saving, and managing in-memory tables.

Discover all actions of table
Data Preparation

Creation of a customer transaction dataset with purchase amounts and tenure in months.

Copied!
1 
2DATA casuser.live_transactions;
3call streaminit(123);
4DO i = 1 to 1000;
5CustomerID = i;
6Amount = rand('Uniform') * 1000;
7Tenure_Months = floor(rand('Uniform') * 60);
8OUTPUT;
9END;
10 
11RUN;
12 

Étapes de réalisation

1
Execute copyTable to filter high-value customers (>500) and compute 'Loyalty_Score' (Tenure * 10).
Copied!
1 
2PROC CAS;
3TABLE.copyTable / TABLE={name='live_transactions', caslib='casuser', where='Amount > 500', computedVars={{name='Loyalty_Score', label='Score'}}, computedVarsProgram='Loyalty_Score = Tenure_Months * 10;
4'}, casout={name='marketing_snapshot', caslib='casuser', replace=true};
5 
6RUN;
7 
2
Verify the content of the new snapshot table.
Copied!
1 
2PROC CAS;
3TABLE.fetch / TABLE={name='marketing_snapshot', caslib='casuser', to=5};
4 
5RUN;
6 

Expected Result


A new table 'marketing_snapshot' is created containing only rows where Amount > 500. It includes a new column 'Loyalty_Score' correctly calculated. The original table remains untouched.