BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mrug12
Calcite | Level 5

Hi I have 2 dataset for example

Table 1

a 1

b 2

c 3

Table 2

a 1

b 1

c 1

a 2

b 2

c 2

a 3

b 3

c 3

how can I seperate non matching records from table-2?

1 ACCEPTED SOLUTION

Accepted Solutions
2much2learn
Calcite | Level 5

And if you only care about non-matching records, SQL is more handy as it does not require sorting:

proc sql;

create table nm as

select * from t2

except

select * from t1;

quit;

Haikuo

View solution in original post

2 REPLIES 2
2much2learn
Calcite | Level 5

I am not 100% sure about what exactly OP wanted, but here to start the discussion:

data t1;

infile cards;

input id $ a;

cards;

a 1

b 2

c 3

;

data t2;

infile cards;

input id $ a;

cards;

a 1

b 1

c 1

a 2

b 2

c 2

a 3

b 3

c 3

;

proc sort data=t1;

by id a;

run;

proc sort data=t2;

by id a;

run;

data m nm;

merge t1 (in=t1) t2(in=t2);

by id a;

if t1 and t2 then output m;

else if t2 and not t1 then output nm;

run;

'm' will be the records shared by two tables, nm will be the records uniquely exist in table2.

Kindly Regards,

Haikuo

2much2learn
Calcite | Level 5

And if you only care about non-matching records, SQL is more handy as it does not require sorting:

proc sql;

create table nm as

select * from t2

except

select * from t1;

quit;

Haikuo

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1620 views
  • 4 likes
  • 2 in conversation