BookmarkSubscribeRSS Feed
damoe213
Calcite | Level 5

Hey guys

 

This is probably really simple but I am having a bit of trouble getting it to work so thought I would ask 🙂

 

I need to create a new data set that omits observations if they are present in a previous data set.

 

For example:

 

Source Data

 

NAME     NUMBER

John        85656

Larry       56464

Tom        38164

 

Old Data Set

 

NAME     NUMBER

Bob         25685

Steve      56468

Tom        38164

 

New Data Set

 

NAME     NUMBER

John        68565

Larry       56464

 

Thanks for any and all help with this.

 

Josh

 

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

You can get the output by merge statement

 

proc sort data=source;
by name;
run;

proc sort data=old;
by name;
run;

data new;
merge source(in=a) old(in=b);
by name;
if a and not b;
run;
Thanks,
Jag
stat_sas
Ammonite | Level 13

proc sql;
create table new as
select * from source
where number not in (select number from old);
quit;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 928 views
  • 1 like
  • 3 in conversation