SPSS Vectors

Vectors are arrays of variable names.


Declaration

Use the VECTOR command to declare a vector.

vector foo = foo1 to foo5
 /bar, baz (5).

A vector can be specified with pre-existing variables using the TO keyword. These variables must be in order in the dataset. They must be either all numeric or all strings. If they are string variables, they must be the same length.

Alternatively, vectors can be declared by creating new variables. Multiple vectors of the same specification can be declared simultaneously by delimiting their names with commas. The created variables are named according to the vector name with a sequential suffix.

Vectors of new variables are specified by a name followed by a parenthesized length. Optionally a format can be specified after the length, otherwise they default to being numeric variables with a F8.2 format.

vector foo (3 A20).

Vectors of scratch variables can also be declared.

vector #foo (10).


Usage

Vector members are indexed like NAME(INDEX).

vector foo (8).
loop #i=1 to 8.
  count foo(#i)=bar to baz (#i).
end loop.


Data Model

Vectors are not stored in datasets. They are available immediately and until the next procedure runs.

Except for vectors of scratch variables, the variables created by a VECTOR command will be stored and will remain.


See also

PSPP manual for VECTOR


CategoryRicottone

SPSS/Vectors (last edited 2023-06-15 17:18:50 by DominicRicottone)