It might be worth switching it to a long format then and grouping to be able to use the formula.
Otherwise a SQL cross join as long as you're willing to type out the formula.
proc sql;
select a.*, b.fx1 as fx12, b.fy1 as fy12 ...,
sqrt[(fx11-fx12)**2+(fy11-fy12)**2]+ sqrt[(fx21-fx22)**2+(fy21-fy22)**2]+...+sqrt[(fx51 -fx52)**2+ (fy51-fy52)**2] as dist
from have as a
cross join have as b;
quit;
... View more