Reputation: 35
I'm trying to create a table in sas that will take observations from a specific column as long as they aren't list in another column in another table.
I've used the code:
proc sql;
create table tbl as
select a.var1, a.var2, a.var3 from
tblA as a, tblB as b
where a.var1~=b.var1;
quit;
Would it be because I've assigned b as a table I'm not selecting a variable from? or is my condition just incorrect?
Upvotes: 1
Views: 34
Reputation: 15865
Your condition is incorrect, you need to tell the tables how to join (where the equality is) THEN tell them that you only want those that dont match.
A left join is used for this:
select a.var1, a.var2, a.var3
from
tblA as a
left join tblB as b on a.var1 = b.var1
where
b.var1 is null
Where a
are the values you want that dont match b
.
See SAS SQL join examples for more
This can also be accomplished using NOT IN
Upvotes: 1