I have two tables table_A and table_B.
table_A
| Queue_nm | Cust_nm |
|---|---|
| ABCD | VERI |
| PQRS | RSTQ |
table_B
| Queue_nm | Act_Cust_nm |
|---|---|
| PQRS | TMOB |
I want to compare the two datasets and if they don't match, then replace the data in table_B in table_A using SAS
data compare_test_2;
set table_A;
set table_B;
if table_A.Queue_nm = table_B.Queue_nm
and tableA.Cust_nm != table_B.Act_Cust_name
then do;
tableA.Cust_nm = table_B.Act_Cust_name
where table_A.Queue_nm = table_B.Queue_nm;
run;
I want the following output after the comparison and the data step
table_A
| Queue_nm | Cust_nm |
|---|---|
| ABCD | VERI |
| PQRS | TMOB |
I get the following error
ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.
ERROR 557-185: Variable table_A is not an object.
You can use SQL to update a table with values from a second table via a correlated subquery using a key variable.
Example:
Another way to update a table in place is the
MODIFYstatement.