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

I have two dataset similar to the examples below, both datasets have different variables. i wanted to read only observations (IDs) that are in both data. 

Dataset one            Dataset two
ID   A   B                           ID   C D
10   1   2                           10   0  4
20   3   4                           30   5  2
30   5   6                           40   7  3

 

I want the output that looks like this

ID   A   B   C  D                   
10   1   2    0  4                     

30   5   6    5  2

                  

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
data want;
    merge one(in=in1) two(in=in2);
    by id;
    if in1 and in2;
run;

In the future, please provide data as SAS data step code, so we can actually use it to test the code we provide. This helps all of us out, and gets you faster and more likely correct answers. Here are the instructions: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/. Do not provide the data in other forms. 

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26
data want;
    merge one(in=in1) two(in=in2);
    by id;
    if in1 and in2;
run;

In the future, please provide data as SAS data step code, so we can actually use it to test the code we provide. This helps all of us out, and gets you faster and more likely correct answers. Here are the instructions: https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/. Do not provide the data in other forms. 

--
Paige Miller

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 541 views
  • 0 likes
  • 2 in conversation