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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 653 views
  • 0 likes
  • 2 in conversation