How to create a spouse variable in SPSS?

Viewed 36

I'm new here and my SPSS knowledge is still pretty basic. I have data from couples, with each couple identified by a household identifier and an individual identifier that is a combination of their household ID plus a designation of whether they're partner 1 or partner 2. I also have a score from each individual on a Likert scale. I want to create a new variable that indicates each participants' spouse's score on that participant's row.

Here's a very simplified version of what my data look like now:

  couple    person   score
     1        11       4
     1        12       3
     2        21       2
     2        22       3
     3        31       5
     3        32       1

Here's what I want my data to look like, with s_score being spouse score:

  couple    person    score      s_score
     1        11        4           3
     1        12        3           4
     2        21        2           3
     2        22        3           2
     3        31        5           1
     3        32        1           5

I found this great post on how to do this in R. This is exactly what I'd like to do, but I'm not sure how to do it in SPSS: How to create spouse variable?

I have a really large dataset, so any advice you can give me would be much appreciated! Thank you!

1 Answers
SORT CASES by couple person (A).
IF couple=lag(couple) s_score=lag(score).

SORT CASES by couple person (D).
IF couple=lag(couple) and miss(s_score) s_score=lag(score).

EXECUTE.

LAG function is looking into the previous row, but it cannot look into the next row. This is why you need to sort twice, once ascending and once descending.

Related