Hello,
I would like to create a table, with the information from Table 1, but I do not want individuals who are not present in Table 2. In sql code.
Thanks for your help.
| Table1 | Table2 | |||||
| ID | Name | ID | Age | |||
| 14 | rt | 15 | 9 | |||
| 15 | fd | 17 | 1 | |||
| 16 | gf | 18 | 2 | |||
| 17 | sq | 19 | 3 | |||
| 18 | pm | |||||
| 19 | er | |||||
| 20 | tr | |||||
| 21 | ea | |||||
| Want | ||||||
| ID | Name | |||||
| 15 | fd | |||||
| 17 | sq | |||||
| 18 | pm | |||||
| 19 | er | |||||
proc sql; create table want as select * from table1 where id not in (select id from table2); quit;
Post test data in the form of a datastep in future please.
proc sql; create table want as select * from table1 where id not in (select id from table2); quit;
Post test data in the form of a datastep in future please.
Provided that your data is properly sortet...
data have1;
input ID $ Name $;
datalines;
14 rt
15 fd
16 gf
17 sq
18 pm
19 er
20 tr
21 ea
;
data have2;
input ID $ Age;
datalines;
15 9
17 1
18 2
19 3
;
data want;
merge have1 have2(in=ina);
by ID;
if ina;
keep ID Name;
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.