Monday, January 30, 2012

Proc SQL - Unmatched Records

1) How to keep only unmatched records from 2 tables;
data a; input varA @@; cards; 200 300 400 500 ; run;
data b; input varB @@; cards;600 700 200 300 ; run;

2) there are 2 tables one is master table with 10 million rows and second has 10000 rows

Need to update the master table records with the records from 2nd table.

Solution
Proc SQL

proc sql;
select VAR, src
from
(Select distinct a.VAR, 'a' as src from work.a a
outer union corr
Select distinct b.VAR, 'b' as src from work.b b
)
group by VAR
having count(VAR) eq 1
;
quit;

No comments:

Post a Comment