table append

Standard Case: Consolidating Daily Customer Interactions for Marketing Analysis

Scénario de test & Cas d'usage

Business Context

A marketing department needs to consolidate daily customer web interaction logs into a master historical table. To comply with privacy regulations, only interactions from customers who have given their consent (`consent_status = 1`) should be added to the main table for weekly campaign analysis.
About the Set : table

Loading, saving, and managing in-memory tables.

Discover all actions of table
Data Preparation

Creates a master table `master_interactions` with historical data and a `daily_clicks` table with new interactions, including a consent flag.

Copied!
1DATA mycas.master_interactions;
2 LENGTH customer_id $ 10 event_type $ 20;
3 INPUT customer_id $ event_type $;
4 DATALINES;
5CUST001 page_view
6CUST002 add_to_cart
7CUST003 purchase
8;
9RUN;
10 
11DATA mycas.daily_clicks;
12 LENGTH customer_id $ 10 event_type $ 20;
13 INPUT customer_id $ event_type $ consent_status;
14 DATALINES;
15CUST004 page_view 1
16CUST005 page_view 0
17CUST006 add_to_cart 1
18CUST007 purchase 1
19CUST008 page_view 0
20;
21RUN;

Étapes de réalisation

1
Verify initial state of the tables by checking row counts.
Copied!
1PROC CAS;
2 TABLE.rowCount / TABLE={caslib='mycas', name='master_interactions'};
3 TABLE.rowCount / TABLE={caslib='mycas', name='daily_clicks'};
4RUN;
2
Append only the consented interactions from the source table to the target table using a 'where' clause.
Copied!
1PROC CAS;
2 TABLE.append /
3 SOURCE={name='daily_clicks', where='consent_status = 1'},
4 target={name='master_interactions'};
5RUN;
3
Check the final row count of the target table to confirm that only the correct number of rows were appended.
Copied!
1 
2PROC CAS;
3TABLE.rowCount / TABLE={caslib='mycas', name='master_interactions'};
4RUN;
5 

Expected Result


The `master_interactions` table should contain its original 3 rows plus the 3 rows from `daily_clicks` where `consent_status` is 1. The final row count should be 6. The two rows with `consent_status = 0` must be excluded.