A marketing analytics team needs to consolidate customer responses from multiple campaign waves into a single master table. The initial data is loaded, and subsequent data from a new wave must be appended without deleting the original records. This scenario tests the 'append' logic and the action's behavior when neither 'append' nor 'replace' is specified on an existing table.
Préparation des Données
Creation of two datasets for two marketing campaign waves.
Copié !
data WORK.CAMPAIGN_WAVE1;\n length customer_id $10 campaign_id $8;\n format response_date date9.;\n do i = 1 to 150;\n customer_id = 'CUST' || put(1000+i, z4.);\n campaign_id = 'CAMP_Q4';\n response_date = '15NOV2025'd - i;\n output;\n end;\nrun;\n\ndata WORK.CAMPAIGN_WAVE2;\n length customer_id $10 campaign_id $8;\n format response_date date9.;\n do i = 1 to 75;\n customer_id = 'CUST' || put(2000+i, z4.);\n campaign_id = 'CAMP_Q4X';\n response_date = '22NOV2025'd - i;\n output;\n end;\nrun;
1
DATA WORK.CAMPAIGN_WAVE1;
2
LENGTH customer_id $10 campaign_id $8;
3
FORMAT response_date date9.;
4
DO i = 1 to 150;
5
customer_id = 'CUST' || put(1000+i, z4.);
6
campaign_id = 'CAMP_Q4';
7
response_date = '15NOV2025'd - i;
8
OUTPUT;
9
END;
10
RUN;
11
12
DATA WORK.CAMPAIGN_WAVE2;
13
LENGTH customer_id $10 campaign_id $8;
14
FORMAT response_date date9.;
15
DO i = 1 to 75;
16
customer_id = 'CUST' || put(2000+i, z4.);
17
campaign_id = 'CAMP_Q4X';
18
response_date = '22NOV2025'd - i;
19
OUTPUT;
20
END;
21
RUN;
Étapes de réalisation
1
Load the first wave of campaign responses into the 'CUSTOMER_RESPONSES' table.
Attempt to load the second wave of data without 'append' or 'replace'. This action should fail or produce a warning, leaving the original table untouched.
Step 1 creates a table with 150 rows. Step 2 should generate an error/warning in the log stating the table exists, and the row count of 'CUSTOMER_RESPONSES' should remain 150. Step 3 should execute successfully. The final verification in Step 4 must show that the 'CUSTOMER_RESPONSES' table has a total of 225 rows (150 from wave 1 + 75 from wave 2).