27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example<br />

MATRIX—END MATRIX 941<br />

LOOP LOCATION = 1, NROW(VEC).<br />

+ DO IF (VEC(LOCATION) = TARGET).<br />

+ BREAK.<br />

+ END IF.<br />

END LOOP.<br />

• This loop searches for the (first) location of a specific value, TARGET, in a vector, VEC.<br />

• The DO IF statement checks whether the vector element indexed by LOCATION equals the<br />

target.<br />

• If so, the BREAK statement transfers control out of the loop, leaving LOCATION as the index<br />

of TARGET in VEC.<br />

READ Statement: Reading Character Data<br />

The READ statement reads data into a matrix or submatrix from a character-format file—that<br />

is, a file containing ordinary numbers or words in readable form. The syntax for the READ<br />

statement is:<br />

READ variable reference<br />

[/FILE = file reference]<br />

/FIELD = c1 TO c2 [BY w]<br />

[/SIZE = size expression]<br />

[/MODE = {RECTANGULAR}]<br />

{SYMMETRIC }<br />

[/REREAD]<br />

[/FORMAT = format descriptor]<br />

• The file can contain values in freefield or fixed-column format. The data can appear in<br />

any of the field formats supported by DATA LIST.<br />

• More than one matrix can be read from a single input record by rereading the record.<br />

• If the end of the file is encountered during a READ operation (that is, fewer values are available<br />

than the number of elements required by the specified matrix size), a warning message<br />

is displayed and the contents of the unread elements of the matrix are unpredictable.<br />

Variable Specification<br />

The variable reference on the READ statement is a matrix variable name, with or without<br />

indexes.<br />

For a name without indexes:<br />

• READ creates the specified matrix variable.<br />

• The matrix need not exist when READ is executed.<br />

• If the matrix already exists, it is replaced by the matrix read from the file.<br />

• You must specify the size of the matrix using the SIZE specification.<br />

For an indexed name:<br />

• READ creates a submatrix from an existing matrix.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!