If you have sas/stat licensed, then the calculation takes only a few lines. Reshaping from the matrix to an edgelist is left as homework.
[pre]
data one;
input id $ x y @@;
cards;
S1 1 2 S2 1 3 S3 2 3 S4 5 6
;
run;
proc distance data=one out=dist shape=square method=euclid;
var ratio(x y);
id id;
run;
/* check */
proc print data=dist noobs;
format s: f6.4;
run;
/* on lst
id S1 S2 S3 S4
S1 0.0000 1.0000 1.4142 5.6569
S2 1.0000 0.0000 1.0000 5.0000
S3 1.4142 1.0000 0.0000 4.2426
S4 5.6569 5.0000 4.2426 0.0000
*/
[/pre]
If you don't have the luxury of having sas/stat licensed, then sql takes only a few lines more:
[pre]
data one;
input id $ x y @@;
cards;
S1 1 2 S2 1 3 S3 2 3 S4 5 6
;
run;
proc sql;
create table dist as
select d1.id as id1, d2.id as id2
, sqrt((d1.x-d2.x)**2 + (d1.y-d2.y)**2) as dist
from one as d1, one as d2
where d1.id not = d2.id
order by d1.id, d2.id;
/* check */
select id1, id2, putn(dist,"6.4") as dist from dist;
quit;
/* on lst
id1 id2 dist
--------------------------
S1 S2 1.0000
S1 S3 1.4142
S1 S4 5.6569
S2 S1 1.0000
S2 S3 1.0000
S2 S4 5.0000
S3 S1 1.4142
S3 S2 1.0000
S3 S4 4.2426
S4 S1 5.6569
S4 S2 5.0000
S4 S3 4.2426
*/
[/pre]