Reputation: 63
I have 2 datasets like below.
dataset ab;
input m;
cards;
102
103
104
run;
dataset ac;
input m;
cards;
102
102
103
103
104
104
104
run;
when i wrote the below statement,
data a;
merge ab ac;
by m;
run;
I got the output as 102 102 103 103 104 104 104
but when i wrote update statement,
data b;
update ab ac;
by m;
run;
i got output as 102 103 104.
Can you please explain me what has happened in the update statement.
Thanks in Advance,
Nikhila
Upvotes: 1
Views: 58
Reputation: 9109
data ab;
input m @@;
cards;
101 102 103 104
;;;;
run;
data ac;
input m @@;
cards;
102 102 103 103 104 104 104
;;;;
run;
data b;
update ab ac(in=in1);
by m;
if first.m then tCount=0;
tCount + in1;
run;
proc print;
run;
Upvotes: 0
Reputation: 21294
Update applies the transactions 1 by 1. The master table is required to have Unique BY values which is true. The transaction table has multiples, but doesn't have any new values so they are not added.
If the transaction had a BY value not in the table it would add it.
With an UPDATE and BY the following may help:
This would be easier to see if you add a second variable to your test datasets that are unique.
Upvotes: 2