Hello,
I have two tables with identical columns A, B, C, D, E, F.
T1 has 2000 values
T2 has 5300 values
These two tables have 4 primary keys: A,C,D,F.
So I want to create a new table and take values from T2 where A,C,D,F are not present in T1.
How do I proceed please?
I have tried proc sql 'except', but it is comparing all columns in both tables
data T1 T2;
input A B C D E F;
if mod(_N_,2) then output T1;
output T2;
cards;
1 2 3 4 5 6
2 3 4 5 6 7
3 4 5 6 7 8
4 5 6 7 8 9
5 6 7 8 9 0
;
run;
proc sql;
select A,C,D,F from T2
except
select A,C,D,F from T1
;
quit;
Hi,
I need all the columns A,B,C,D,E,F in the output table. But I need to compare only the four primary keys A,C,D,F.
proc sql;
select * from T2
natural inner join
(
select A,C,D,F from T2
except
select A,C,D,F from T1
)
;
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: