user11290253
user11290253

Reputation:

Selecting cases based on values in previous rows

I have a binominal value in SPSS called "emotion" that contains "91" and "95". I would like to select all cases that come after twice "95" and are encoded with "91" themselves. Does anybody know a synthax that makes this possible?

Upvotes: 1

Views: 46

Answers (1)

eli-k
eli-k

Reputation: 11350

Make sure your data is sorted in the relevant order, then run this:

compute selectthis=(yourvar=91 and lag(yourvar)=95 and lag(yourvar,2)=95).
exe.
select if selectthis=1.

Upvotes: 1

Related Questions