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
45
46
47
48
49
50
51
DATA LIST LIST /a (F8) b (F8) c(F8).
BEGIN DATA
1 2 3
4 5 6
7 8 9 
END DATA.


* read matrix data from a regular spss sav file.
MATRIX.
GET M /VARIABLES= a TO c.
PRINT M /TITLE='Original matrix'.
COMPUTE N=M*M.
PRINT N /TITLE='Matrix squared'.
COMPUTE I=1/M.
PRINT I /TITLE='Matrix of inverse of each element'.
END MATRIX.

* If data is already in SPSS matrix data, use the MGET statement.
MGET Statement: Reading SPSS Matrix Data Files
MGET reads an SPSS matrix-format data file. MGET puts the data it reads into separate matrix
variables. It also names these new variables automatically. The syntax of MGET is as follows:
MGET [ [/] FILE = file reference]
[/TYPE = {COV }]
{CORR }
{MEAN }
{STDDEV}
{N }
{COUNT }
· Since MGET assigns names to the matrices it reads, do not specify matrix names on the
MGET statement. 

*If data is in an ASCII file use the READ statement.
READ Statement: Reading Character Data
The READ statement reads data into a matrix or submatrix from a character-format file—that
is, a file containing ordinary numbers or words in readable form. The syntax for the READ
statement is:
READ variable reference
[/FILE = file reference]
/FIELD = c1 TO c2 [BY w]
[/SIZE = size expression]
[/MODE = {RECTANGULAR}]
{SYMMETRIC }
[/REREAD]
[/FORMAT = format descriptor]
· The file can contain values in freefield or fixed-column format. The data can appear in
any of the field formats supported by DATA LIST.
· More than one matrix can be read from a single input record by rereading the record.
· If the end of the file is encountered during a READ operation (that is, fewer values are avail-able
than the number of elements required by the specified matrix size), a warning message
is displayed and the contents of the unread elements of the matrix are unpredictable.