proc sql;
Select a.id, a.var2, b.*
From tablea a, tableb b
Where a.id = b.id; Above performs an ‘Inner join’ of all records in a and b, matched on id, with columns in select list from both tables and potentially multiple rows for a single id from tablea if multiple matches in tableb (i.e. one to many relationship) proc sql;
Select *
From tablea
where id in
(select distinct id from tableb); Whereas, latter returns all records from tablea with an id that exists in tableb (or the complement, i.e. returns if doesn’t exist, if NOT IN used). WHERE IN (sub-query) does not join the tables and you cannot select other variables from tableb in your select list. Also, if you have a one to many relationship between the two tables, using a sub-query will only return one row per record from tablea.
... View more