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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.