Previous: , Up: Matrices   [Contents][Index]


16.4 MATRIX

MATRIX.matrix commandsEND MATRIX.

The following basic matrix commands are supported:

COMPUTE variable[(index[,index])]=expression.
CALL procedure(argument, …).
PRINT [expression]
      [/FORMAT=format]
      [/TITLE=title]
      [/SPACE={NEWPAGE | n}]
      [{/RLABELS=string| /RNAMES=expression}]
      [{/CLABELS=string| /CNAMES=expression}].

The following matrix commands offer support for flow control:

DO IF expression.matrix commands…
[ELSE IF expression.matrix commands…]…
[ELSEmatrix commands…]
END IF.

LOOP [var=first TO last [BY step]] [IF expression].matrix commandsEND LOOP [IF expression].

BREAK.

The following matrix commands support matrix input and output:

READ variable[(index[,index])]
     [/FILE=file]
     /FIELD=first TO last [BY width]
     [/FORMAT=format]
     [/SIZE=expression]
     [/MODE={RECTANGULAR | SYMMETRIC}]
     [/REREAD].
WRITE expression
      [/OUTFILE=file]
      /FIELD=first TO last [BY width]
      [/MODE={RECTANGULAR | TRIANGULAR}]
      [/HOLD]
      [/FORMAT=format].
GET variable[(index[,index])]
    [/FILE={file | *}]
    [/VARIABLES=variable…]
    [/NAMES=expression]
    [/MISSING={ACCEPT | OMIT | number}]
    [/SYSMIS={OMIT | number}].
SAVE expression
     [/OUTFILE={file | *}]
     [/VARIABLES=variable…]
     [/NAMES=expression]
     [/STRINGS=variable…].
MGET [/FILE=file]
     [/TYPE={COV | CORR | MEAN | STDDEV | N | COUNT}].
MSAVE expression
      /TYPE={COV | CORR | MEAN | STDDEV | N | COUNT}
      [/OUTFILE=file]
      [/VARIABLES=variable…]
      [/SNAMES=variable…]
      [/SPLIT=expression]
      [/FNAMES=variable…]
      [/FACTOR=expression].

The following matrix commands provide additional support:

DISPLAY [{DICTIONARY | STATUS}].
RELEASE variable.

MATRIX and END MATRIX enclose a special PSPP sub-language, called the matrix language. The matrix language does not require an active dataset to be defined and only a few of the matrix language commands work with any datasets that are defined. Each instance of MATRIXEND MATRIX is a separate program whose state is independent of any instance, so that variables declared within a matrix program are forgotten at its end.

The matrix language works with matrices, where a matrix is a rectangular array of real numbers. An n×m matrix has n rows and m columns. Some special cases are important: a n×1 matrix is a column vector, a n is a row vector, and a 1×1 matrix is a scalar.

The matrix language also has limited support for matrices that contain 8-byte strings instead of numbers. Strings longer than 8 bytes are truncated, and shorter strings are padded with spaces. String matrices are mainly useful for labeling rows and columns when printing numerical matrices with the MATRIX PRINT command. Arithmetic operations on string matrices will not produce useful results. The user should not mix strings and numbers within a matrix.

The matrix language does not work with cases. A variable in the matrix language represents a single matrix.

The matrix language does not support missing values.

MATRIX is a procedure, so it cannot be enclosed inside DO IF, LOOP, etc.

Macros may be used within a matrix program, and macros may expand to include entire matrix programs. The DEFINE command may not appear within a matrix program. See DEFINE, for more information about macros.

The following sections describe the details of the matrix language: first, the syntax of matrix expressions, then each of the supported commands. The COMMENT command (see COMMENT) is also supported.


Previous: MCONVERT, Up: Matrices   [Contents][Index]