Let me share a way in array.
data test01;
input a b;
call sortn(a,b);
output;
cards;
3 2
3 4
4 3
4 2
1 2
2 1
2 3
;run;
proc sort data = test01 nodupkey; by _all_; run;
data test02;
set test01
test01(rename=(b=a a=b));
value = 1;
run;
proc sort data = test02; by a b;run;
proc transpose data = test02 out = test03(drop = _NAME_);
id b;
by a;
run;
proc sql noprint;
select count(*) into:n from test03;
quit;
%let _end = %sysfunc(compress(_&n.));
data test04(keep = a b dup);
format a b dup 8.;
array m(&n.,&n.) _temporary_;
array ra(*) _1-&_end.;
do ii = 1 to &n.;
set test03 point = ii;
do jj = 1 to &n.;
m(ii,jj) = ra(jj);
end;
end;
do ii = 1 to &n.;
do jj = ii+1 to &n.;
dup = 0;
do kk = 1 to &n.;
dup = sum(dup, m(ii,kk)+m(jj,kk));
end;
dup = dup / 2;
a = ii;
b = jj;
output;
end;
end;
stop;
run;
|