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

Hi,

I need help in flagging the ID's.

dataset1    dataset2

ID                  ID

1                     1

2                     3

3                     5

4

I need to flag the identical ID's

in the above example I need to flag dataset1 which has same ID as dataset2. like ID's 1 3 5 needs to be flagged.

 

thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

data flaged;

 merge dataset1(in=in1)

           dataset2(in=in2);

   by ID;

       if in1;

       if in2 then flag=1; else flag=0;

run;

View solution in original post

2 REPLIES 2
Shmuel
Garnet | Level 18

data flaged;

 merge dataset1(in=in1)

           dataset2(in=in2);

   by ID;

       if in1;

       if in2 then flag=1; else flag=0;

run;

ballardw
Super User

What does the output look like?

 

Is the data currently sorted by Id?

 

Are there duplicates of ID in either of the sets? If so which one(s)? And what would the output for duplicates look like?

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!

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