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
* Example of working with matrices.
* At the end of the syntax, the data editor contains the value of vector md.
* posted to SPSSX-L list by Raynald Levesque on 2004/02/22.

DATA LIST LIST /V1, V2, V3 ,V4 W1, W2, W3, W4 .
BEGIN DATA 
1 1 1 1 5 5 5 5
2 2 2 2 6 6 6 6 
3 3 3 3 7 7 7 7 
4 5 6 7 8 8 8 8 
END DATA.


SET MXLOOPS=300 /MPRINT=yes.

*MMMMMMMMMMMMM.
MATRIX.
GET X 
  /VARIABLES = V1, V2, V3 ,V4
  /FILE=* .
GET W
  /VARIABLES =w1 w2 w3 w4
  /FILE=* .
COMPUTE wt={2}.
COMPUTE c={3} .
PRINT X.
PRINT W.
COMPUTE d={NROW(W)*NROW(X)}.
COMPUTE md={1:d}.
PRINT md.
LOOP I = 1 TO NROW(W).
- LOOP F=1 TO NROW (X).
-   COMPUTE RI = W(I, :) - X(F,:).
-   PRINT WT.
-   COMPUTE D = RI*WT*C*T(RI).
-   COMPUTE MD((I-1)*NROW(X) + F) = SQRT(D).
-   PRINT MD((I-1)*NROW(X) + F).
- END LOOP.
END LOOP.

SAVE TRANSPOS(md) /OUTFILE=* /VARIABLES md. 
END MATRIX.
*MMMMMMMMMMMMM.