Q:

Comparing values between lines within a group

I'm looking to create a column denoting if a survey respondent has changed locations from Wave 6 to Wave 7.  I do not care about previous waves (although they are there in the data).  
So the logic I want is: If the email from Wave 6= the email from Wave 7 and location from 6 <> location from 7 then 1.  So I'm only concerned about respondents that show up in both waves 6 and 7.  
Here is an example of the output that I would want: (I want the 1 to appear both on Wave 6 and Wave 7, denoting the change for both waves). 

I'm unsure how to logically write this in SPSS.  Any tips would be appreciated.  Thanks!  

A:

Many ways to do this, so here's one that should work assuming there is only one occurrence of every wave X Email_A combination:
sort cases by Email_A wave. 
compute changeLocation=
   (Email_A=lag(Email_A) and wave=7 and lag(wave)=6 and location<>lag(location)). 

at this point you have the 1 in every relevant row of wave=7.  Now to get this to the wave=6 rows there are also a few ways but here's a fun one:
sort cases by Email_A wave (d). 
if Email_A=lag(Email_A) and wave=6 and lag(changeLocation)=1 changeLocation=1.