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.

1656 VECTOR<br />

<strong>Syntax</strong> Rules<br />

• Multiple vectors can be created on the same command by using a slash to separate each<br />

set of specifications.<br />

• Variables specified on VECTOR must already be defined unless the short form of VECTOR<br />

is used to create variables (see “VECTOR: Short Form” on p. 1657).<br />

• The TO convention must be used to specify the variable list. Thus, variables specified<br />

must be consecutive and must be from the same dictionary, permanent or scratch.<br />

• A single vector must comprise all numeric variables or all string variables. The string<br />

variables must have the same length.<br />

• A scalar (a variable named on NUMERIC), a function, and a vector can all have the same<br />

name, for example MINI. The scalar can be identified by the lack of a left parenthesis<br />

following the name. Where a vector has the same name as a function (or the abbreviation<br />

of a function), the vector name takes precedence. (See p. 1658 for an example.)<br />

• Vector element names must always be specified with a subscript in parentheses.<br />

Operations<br />

Examples<br />

• VECTOR takes effect as soon as it is encountered in the command sequence, unlike most<br />

transformations, which do not take effect until the data are read. Thus, special attention<br />

should be paid to its position among commands (see “<strong>Command</strong> Order” on p. 8 in<br />

Volume I).<br />

• VECTOR is in effect only until the first procedure that follows it. The vector must be redeclared<br />

to be reused.<br />

• Vectors can be used in transformations but not in procedures.<br />

* Replace a case’s missing values with the mean of all<br />

nonmissing values for that case.<br />

DATA LIST FREE /V1 V2 V3 V4 V5 V6 V7 V8.<br />

MISSING VALUES V1 TO V8 (99).<br />

COMPUTE MEANSUB=MEAN(V1 TO V8).<br />

VECTOR V=V1 TO V8.<br />

LOOP #I=1 TO 8.<br />

+ DO IF MISSING (V(#I)).<br />

+ COMPUTE V(#I)=MEANSUB.<br />

+ END IF.<br />

END LOOP.<br />

BEGIN DATA<br />

1 99 2 3 5 6 7 8<br />

2 3 4 5 6 7 8 9<br />

2 3 5 5 6 7 8 99<br />

END DATA.<br />

LIST.

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

Saved successfully!

Ooh no, something went wrong!