1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| data toto;
input paire $ v1;
cards;
p1-p2 1
p1-p3 1
p1-p4 1
p1-p5 0
p2-p3 1
p2-p4 1
p2-p5 1
p3-p4 0
p3-p5 1
p4-p5 1
;
run;
data titi (drop=paire);
set toto;
length ligne 3. colonne 3.;
ligne=substr(paire,2,1);
colonne=substr(paire,5,1);
if v1=1;
run;
proc iml;
use titi;
read all var _num_ into titi;
close titi;
print titi;
matrice=J(5,5,0);
print matrice;
do j=1 to 5;
matrice[j,j]=1;
end;
do i=1 to nrow(titi);
if titi[i,2]=titi[i,3] then matrice[(titi[i,2]),(titi[i,2])]=1;
if titi[i,1]=1 then matrice[(titi[i,2]),(titi[i,3])]=1;
if titi[i,1]=1 then matrice[(titi[i,3]),(titi[i,2])]=1;
end;
print matrice;
create matrcie from matrice;
append from matrice;
quit; |
Partager