Tech Tip: The Any Function in IBM SPSS Statistics

9
The ANY function in IBM SPSS Statistics

Transcript of Tech Tip: The Any Function in IBM SPSS Statistics

Page 1: Tech Tip: The Any Function in IBM SPSS Statistics

The ANY function

in IBM SPSS Statistics

Page 2: Tech Tip: The Any Function in IBM SPSS Statistics

The ANY function

• A very useful logical function

- ANY(test, value1, value2, ....)

• Returns a value of 1 if the test is true and 0 otherwise.

• e.g. ANY(var1, 1, 3, 5)

- Will return a value of 1 if var1 has a value of 1, 3 or 5.

Otherwise it will return a value of 0

• Instead of using a series of or statements

- ANY(var1, 1, 3, 5) = (var1=1 or var1=3 or var1=5)

2

Page 3: Tech Tip: The Any Function in IBM SPSS Statistics

The ANY function

The ANY function can also be used to scan a list of variables

or expressions for a value

.For example ANY(1, var1, var2, var3) returns a value of 1 if

any the specified variables have a value of 1, otherwise it will

return a value of 0.

The equivalent logical statement using or statements would

be

• (var1=1 or var2=1 or var3=1)

3

Page 4: Tech Tip: The Any Function in IBM SPSS Statistics

Sample file: cable_survey.sav

4

Page 5: Tech Tip: The Any Function in IBM SPSS Statistics

An example of the ANY function

Using cable_survey.sav located in

C:\Program Files\IBM\SPSS\Statistics\*Version\Samples\English

*Version: Your SPSS Statistics Version, e.g. 20, 21, 22,…

We will use the ANY function

in the select cases procedure

to create a new dataset with

categories 1, 3 and 4 of the

variable hometype

5

Page 6: Tech Tip: The Any Function in IBM SPSS Statistics

Select Cases

Data -> Select Cases -> If condition is satisfied

6

Page 7: Tech Tip: The Any Function in IBM SPSS Statistics

Select cases out to a new dataset

Create a new dataset

7

Page 8: Tech Tip: The Any Function in IBM SPSS Statistics

View the Results

8