Hello:
I would like to find out the same ID from two variables ID1 and ID2. Then, I created new variable "Same" to see if there is, and flag it with number 1, and count the total number of the same ID. However, the new "same" column is '.' which it is not the result I would like to. I would like to match result shown as the attachment. What is the problem?
data test1;
input ID HR Score;
cards;
1 89 60
2 69 61
3 49 62
4 85 63
5 56 64
6 75 65
7 90 66
;
run;
data test2;
input ID TR Score;
cards;
2 60 50
4 61 40
6 62 60
8 63 65
9 64 78
10 65 79
11 66 90
;
run;
data testID1;
set test1 (keep=ID);
by ID;
run;
data testID2;
set test2 (keep=ID);
by ID;
run;
data test12;
merge testID1(in=intestID1 rename=(ID=ID1))
testID2(in=intestID2 rename=(ID=ID2));
run;
data test13;
set test12;
if ID1 = ID2 then
same = 1;
by ID2;
run;
There's no BY statement in your MERGE.
Also, how to count the total number of the same ID. Please see the attachment.
Is your original question answered?
If so, mark this question as solved and please ask a new one.
I won't open attachments so post everything directly into the forum.
Hi, Reeza: I have added by on the merged dataset. It doesn't work.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.