title: Comparing or combining values in a column
body: <p><strong>Scenario and question:</strong><br />
  Basically I have results for a matched pair survey of couples in SPSS. It's set up where the person A's answers to questions 1-10 are the first 10 variables and then person B's answers to questions 1-10 are the next 10 variables. But I need to run tests and produce crosstabs for individuals, so if I have 20 couples the crosstabs outputs should be out of 40. I was able to simply select all the data for the &quot;person B&quot;s in couples and just copy and paste it over, however  I lost couple-specific data and I still need to be able to create new variables based on the matched pair information. My way around this was creating a new variable while still in matched pair form called CoupleNum, so even when they were in individual form I could say if their couple number equaled each other calculate this or that. But I don't actually know how to do this. <strong>In the same dataset, how do I compare rows for the same variable?</strong></p>
  <p><strong>Example for what I'm talking about:</strong></p>
  <p>Here's fake data</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>A_CoupleNum</th>
  <th>A1_HappyScale</th>
  <th>B_CoupleNum</th>
  <th>B1_HappyScale</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>6</td>
  <td>1</td>
  <td>4</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2</td>
  <td>2</td>
  <td>3</td>
  </tr>
  <tr>
  <td>3</td>
  <td>9</td>
  <td>3</td>
  <td>7</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I'd move it to individual form like</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>CoupleNum</th>
  <th>HappyScale</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>6</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2</td>
  </tr>
  <tr>
  <td>3</td>
  <td>9</td>
  </tr>
  <tr>
  <td>1</td>
  <td>4</td>
  </tr>
  <tr>
  <td>2</td>
  <td>3</td>
  </tr>
  <tr>
  <td>3</td>
  <td>7</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>And then I'd want to be able to make a new variable called CoupleHappiness that was the HappyScale for each person in the couple added together.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>CoupleNum</th>
  <th>HappyScale</th>
  <th>CoupleHappiness</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>6</td>
  <td>10</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2</td>
  <td>5</td>
  </tr>
  <tr>
  <td>3</td>
  <td>9</td>
  <td>16</td>
  </tr>
  <tr>
  <td>1</td>
  <td>4</td>
  <td>10</td>
  </tr>
  <tr>
  <td>2</td>
  <td>3</td>
  <td>5</td>
  </tr>
  <tr>
  <td>3</td>
  <td>7</td>
  <td>16</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>So essentially I'd want to code something like</p>
  <pre><code>if CoupleNum = CoupleNum CoupleHappiness = HappyScale + HappyScale
  </code></pre>
  <p>I know this is definitely not correct but hopefully it gets my point across and what I'd like to do.</p>
  <p><strong>Potential solutions I've found that don't work/I don't know how to make them work for my needs:</strong><br />
  Since I'm new to SPSS, I've found several things that might work but I don't know SPSS syntax well enough to suit them for my needs. I've noticed people mention things like LAG functions or CREATE + LEAD if they were in adjacent rows, but they could be all over the place. Someone also mentioned using case numbers but I don't exactly understand that.</p>
  <p>Sorry this was a really long question but I would appreciate any help!!</p>