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

Hi, 

 

I have two datasets with different variables. But both datasets have a variable "sequence number" to represent observations. I want to know how many observations are different from each other (or how many observations are not in dataset 1 but in dataset 2). I also want to create a new dataset with variables in dataset 2.

 

Dataset 1:

seqn variable1 variable 2

1          3                2

3          4               2

......

 

dataset 2:

seqn variable3 variable 4

1          1               4

2         2                3

3          2              3

......

 

dataset I want:

seqn variable3 variable 4

2         2                3

......

 

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
data want;
    merge dataset1(in=in1) dataset2(in=in2);
    by seqn;
    if in2 and not in1;
run;
--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26
data want;
    merge dataset1(in=in1) dataset2(in=in2);
    by seqn;
    if in2 and not in1;
run;
--
Paige Miller
knighsson
Obsidian | Level 7
Thank you, could you explain What (in=in1) means?

Thank you!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 4 replies
  • 873 views
  • 0 likes
  • 2 in conversation