SPSS tutorials

BASICS DATA ANALYSIS T-TEST ANOVA CHI-SQUARE TEST

Compute A = B = C

Summary

A great way to dichotomize variables is with a single short compute command. This is also the fastest way to create multi variable filters.

How Does it Work?

When the structure COMPUTE A = B = C is used, SPSS will evaluate whether (B = C) is True or False for each case. The outcome variable A will be the following

A nice extra here is that the outcome variable A is perfect for using with FILTER.

Multiple Conditions

More complex conditions can be used in a similar vein, such as COMPUTE FLAG = V1 GT V2 AND V3 = 5.. This would mean the following:

SPSS Syntax Examples

*1. Create test data.

data list free/v1 v2.
begin data
1 6 '' 5 3 4 4 3 5 2 6 1
end data.

*2. Flag cases where v1 is greater than (gt) 2.

compute flag.1 = v1 gt 2.

*3. Flag cases where both v1 and v2 gt 2.

compute flag.2 = v1 gt 2 and v2 gt 2.
exe.

Previous tutorial: SPSS Command Types

Next tutorial: SPSS – Open CSV Data File

Let me know what you think!

*Required field. Your comment will show up after approval from a moderator.

This tutorial has 2 comments