SPSS ANY Function

Definition

SPSS’ ANY is used to compare one value to a set of other values.

SPSS Any – Basics

  • ANY(a,b,c[,d...]) checks whether a is equal to any of the b, c[,d...].
  • Note that the first value is compared to the second through the last values.
  • Each of these can either be a constant (“6”) or a variable (“v1”) over respondents.

SPSS Any – Examples

  • Suppose we have 10 respondents throw a dice 4 times. The following questions are best answered by using ANY as we’ll demonstrate in the syntax below.
  • Did the first throw result in either a 1, a 4 or a 5?
  • Did the respondent throw any 6 during his four attempts?
  • Did the outcome of the first throw occur in any of the subsequent throws?
  • Was the outcome of the last throw either equal to 6 or the first throw ?

SPSS Any – Syntax Examples

* Create tiny dataset.

data list free/id.
begin data
1 2 3 4 5 6 7 8 9 10
end data.

do repeat v = throw_1 to throw_4.
compute v = trunc(rv.uniform(1,7)).
end repeat.
exe.

*1. Did the first throw result in one of the values 1, 4, 5?.

compute check_1 = any(throw_1,1,4,5).

*2. Was there any 6 among the four attempts?.

compute check_2 = any(6,throw_1 to throw_4).

*3. Did the outcome of the first throw occur in any of the subsequent throws?.

compute check_3 = any(throw_1,throw_2 to throw_4).

*4. Was the outcome of the last throw either equal to 6 or the first throw ?.

compute check_4 = any(throw_4,throw_1, 6).

value labels check_1 to check_4 0 ‘No’ 1 ‘Yes’.
exe.

Note

TRUNC(RV.UNIFORM(1,7)) generates random integer values from 1 through 6 with equal probabilities. Hence it simulates throws with a balanced die. Also, see RV.UNIFORM.

Post Author: Zahid Farid