Hello,
I have two table I want to remove the individuals from table 1 who are not present in table 2.
Thanks for your help.
| Table 1 | Table 2 | |||
| Nom | Argent | Nom | F | |
| Toto | 5 | William | o | |
| Titi | 4 | Mathias | o | |
| Henru | 3 | |||
| Sophie | 4 | |||
| Didier | 6 | |||
| william | 3 | |||
| Nelson | 4 | |||
| Mathias | 8 | |||
| Table 3 | ||||
| Nom | Argent | |||
| william | 3 | |||
| Mathias | 8 |
data Table1;
input Nom $ Argent;
datalines;
Toto 5
Titi 4
Henru 3
Sophie 4
Didier 6
William 3
Nelson 4
Mathias 8
;
data Table2;
input Nom $ F $;
datalines;
William o
Mathias o
;
proc sql;
create table Table3 as
select * from Table1
where Nom in (Select distinct Nom from Table2);
quit;
Or a data step approach
data Table3;
if _N_=1 then do;
declare hash h(dataset:'Table2');
h.definekey('Nom');
h.definedone();
end;
set Table1;
if h.find()=0;
run;
Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.
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.
Ready to level-up your skills? Choose your own adventure.