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.

256 COMPUTE<br />

• The last two examples above illustrate the use of parentheses to control the order of<br />

execution. For a case with value 2 for X and Y, TEST equals 0.5, since 2 divided by 2 (X/Y)<br />

is 1, the square root of 1 is 1, truncating 1 returns 1, and 1 times 0.5 is 0.5. However,<br />

PARENS equals 0 for the same case, since SQRT(X/Y) is 1, 1 times 0.5 is 0.5, and<br />

truncating 0.5 returns 0.<br />

Statistical Functions<br />

COMPUTE NEWSAL = SUM(SALARY,RAISE).<br />

COMPUTE MINVAL = MIN(V1,V2,V3,V4).<br />

COMPUTE MEANVAL = MEAN(V1,V2,V3,V4).<br />

COMPUTE NEWMEAN = MEAN.3(V1,V2,V3,V4).<br />

• NEWSAL is the sum of SALARY plus RAISE.<br />

• MINVAL is the minimum of the values for V1 to V4.<br />

• MEANVAL is the mean of the values for V1 to V4. Since the mean can be computed for one,<br />

two, three, or four values, MEANVAL is assigned a valid value as long as any one of the<br />

four variables has a valid value for that case.<br />

• In the last example above, the .3 suffix specifies the minimum number of valid arguments<br />

required. NEWMEAN is the mean of variables V1 to V4 only if at least three of these<br />

variables have valid values. Otherwise, NEWMEAN is system-missing for that case.<br />

Missing-Value Functions<br />

MISSING VALUE V1 V2 V3 (0).<br />

COMPUTE ALLVALID=V1 + V2 + V3.<br />

COMPUTE UM=VALUE(V1) + VALUE(V2) + VALUE(V3).<br />

COMPUTE SM=SYSMIS(V1) + SYSMIS(V2) + SYSMIS(V3).<br />

COMPUTE M=MISSING(V1) + MISSING(V2) + MISSING(V3).<br />

• The MISSING VALUE command declares value 0 as missing for V1, V2, and V3.<br />

• ALLVALID is the sum of three variables only for cases with valid values for all three<br />

variables. ALLVALID is assigned the system-missing value for a case if any variable in the<br />

assignment expression has a system- or user-missing value.<br />

• The VALUE function overrides user-missing value status. Thus, UM is the sum of V1, V2,<br />

and V3 for each case, including cases with value 0 (the user-missing value) for any of the<br />

three variables. Cases with the system-missing value for V1, V2, and V3 are system-missing.<br />

• The SYSMIS function on the third COMPUTE returns the value 1 if the variable is systemmissing.<br />

Thus, SM ranges from 0 to 3 for each case, depending on whether variables V1,<br />

V2, and V3 are system-missing for that case.<br />

• The MISSING function on the fourth COMPUTE returns the value 1 if the variable named is<br />

system- or user-missing. Thus, M ranges from 0 to 3 for each case, depending on whether<br />

variables V1, V2, and V3 are user- or system-missing for that case.

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

Saved successfully!

Ooh no, something went wrong!