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.

VECTOR 1659<br />

• In this example, there are potential name conflicts between the scalars (the variables<br />

named on NUMERIC), the vectors (named on VECTOR), and the statistical function<br />

MINIMUM.<br />

• A name that is not followed by a left parenthesis is treated as a scalar.<br />

• When a name followed by a left parenthesis may refer to a vector element or a function,<br />

precedence is given to the vector.<br />

VECTOR outside a Loop Structure<br />

VECTOR is most commonly associated with the loop structure, since the index variable for<br />

LOOP can be used as the subscript. However, the subscript can come from elsewhere,<br />

including from the data.<br />

Example<br />

* Create a single case for each of students 1, 2, and 3.<br />

DATA LIST /STUDENT 1 SCORE 3-4 TESTNUM 6.<br />

BEGIN DATA<br />

1 10 1<br />

1 20 2<br />

1 30 3<br />

1 40 4<br />

2 15 2<br />

2 25 3<br />

3 40 1<br />

3 55 3<br />

3 60 4<br />

END DATA.<br />

VECTOR RESULT(4).<br />

COMPUTE RESULT(TESTNUM)=SCORE.<br />

AGGREGATE OUTFILE=*/BREAK=STUDENT<br />

/RESULT1 TO RESULT4=MAX(RESULT1 TO RESULT4).<br />

PRINT FORMATS RESULT1 TO RESULT4 (F2.0).<br />

PRINT /STUDENT RESULT1 TO RESULT4.<br />

EXECUTE.<br />

• Data are scores on tests recorded in separate cases along with a student identification<br />

number and a test number. In this example, there are four possible tests for three students.<br />

Not all students took every test.<br />

• Vector RESULT creates variables RESULT1 through RESULT4.<br />

• For each case, COMPUTE assigns the SCORE value to one of the four vector variables,<br />

depending on the value of TESTNUM. The other three vector variables for each case keep<br />

the system-missing value they were initialized to.

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

Saved successfully!

Ooh no, something went wrong!