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

Hi All,

I have a question with merging two datasets. I want to merge table A with table B and get all the observations in table A that doesn't match with table B. I don't want the matched observations. I have something like this for all matched observations from table A and matching with table B.

 

DATA matched1; MERGE test1(IN = a) test2;
    BY  gender age;
 IF a;
RUN;

 

I know this gives all the observations from test1 and those matching from test2. But I want the non-matched one, can I do something like this:

 

DATA matched1; MERGE test1(IN = a) test2(in=b);
    BY  gender age;
 IF a and not b; /*Not sure if this is the right statement to use in SAS*/
RUN;

 

Please advise!

 

Thank you,

Malathi

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Your second DATA step is correct for what you want. There is no harm in testing it for yourself to see if it gives your the results you want.

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

Your second DATA step is correct for what you want. There is no harm in testing it for yourself to see if it gives your the results you want.

Ksharp
Super User

if  not b ;

Malathi13
Obsidian | Level 7
Thank you Ksharp!

M

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 3 replies
  • 454 views
  • 2 likes
  • 3 in conversation