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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

52 Universals<br />

Order of Evaluation<br />

• When arithmetic operators and functions are used in a logical expression, the order of<br />

operations is functions and arithmetic operations first, then relational operators, and then<br />

logical operators.<br />

• When more than one logical operator is used, NOT is evaluated first, then AND, and then OR.<br />

• To change the order of evaluation, use parentheses.<br />

Missing Values in Logical Expressions<br />

In a simple relation, the logic is indeterminate if the expression on either side of the relational<br />

operator is missing. When two or more relations are joined by logical operators AND and OR,<br />

SPSS always returns a missing value if all of the relations in the expression are missing.<br />

However, if any one of the relations can be determined, SPSS tries to return true or false<br />

according to the logical outcomes shown in Table 5.<br />

• When two relations are joined with the AND operator, the logical expression can never be<br />

true if one of the relations is indeterminate. The expression can, however, be false.<br />

• When two relations are joined with the OR operator, the logical expression can never be<br />

false if one relation returns missing. The expression, however, can be true.<br />

Other Functions<br />

SPSS also includes a lag function and several missing-value functions.<br />

LAG Function<br />

LAG(arg,n) The value of the variable n cases before. The first argument is a variable. The<br />

second argument, if specified, is a constant and must be a positive integer;<br />

the default is 1. For example, PREV4=LAG(GNP,4) returns the value of GNP<br />

for the fourth case before the current one. The first four cases have systemmissing<br />

values for PREV4.<br />

• The result is of the same type (numeric or string) as the variable specified as the first<br />

argument.<br />

• The first n cases for string variables are set to blanks. For example, if PREV2=LAG<br />

(LNAME,2) is specified, blanks will be assigned to the first two cases for PREV2.<br />

• When LAG is used with commands that select cases (for example, SELECT IF and SAMPLE),<br />

LAG counts cases after case selection, even if specified before these commands (see<br />

“<strong>Command</strong> Order” on p. 8).<br />

Note: In a series of transformation commands without any intervening EXECUTE commands<br />

or other commands that read the data, lag functions are calculated after all other transformations,<br />

regardless of command order. For example:<br />

COMPUTE lagvar=LAG(var1).<br />

COMPUTE var1=var1*2.

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

Saved successfully!

Ooh no, something went wrong!