Reputation: 192
I have a dataset with two columns of IDs, ID_A and ID_B. Each row contains two ID's that I believe belong to the same person. Because of this, each combination shows up twice. For example:
ID_A ID_B
A B
C D
B A
D C
What I want is to remove the repetition. I.E. If I have the row A, B I don't require the row B, A.
ID_A ID_B
A B
C D
Any idea how to do this in SAS?
Upvotes: 0
Views: 46
Reputation: 3315
I like @data null answer is perfect and robust. You can also try proc sql as shown below
proc sql;
create table want as
select distinct
case when ID_A le ID_B then ID_A else ID_B end as ID_A,
case when ID_A ge ID_B then ID_A else ID_B end as ID_B
from have;
Upvotes: 0
Reputation: 9109
How about this...
data have;
input (ID_A ID_B)($);
cards;
A B
C D
B A
D C
;;;;
run;
data haveV / view=haveV;
set have;
call sortc(of id:);
run;
proc sort nodupkey out=want;
by id:;
run;
proc print;
run;
Upvotes: 2