New to Sas.

Reply
Occasional Learner
Posts: 1

New to Sas.

Hey guys

 

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

 

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

 

Super User
Posts: 1,103

Re: New to Sas.

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
Trusted Advisor
Posts: 1,203

Re: New to Sas.

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

Ask a Question
Discussion stats
  • 2 replies
  • 202 views
  • 1 like
  • 3 in conversation