title: How to compute the sum of some variables in Stata?
body: <p>I have 48 variables in my dataset: first 12 concern year 2000, second 12 year 2001, third 12 year 2002 and fourth 12 year 2003.
  Each single variable contains the values in such a way:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">ID</th>
  <th style="text-align: center;">var1</th>
  <th style="text-align: center;">var2</th>
  <th style="text-align: center;">var3</th>
  <th style="text-align: center;">...</th>
  <th style="text-align: center;">var12</th>
  <th style="text-align: center;">...</th>
  <th style="text-align: right;">var48</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">xx</td>
  <td style="text-align: center;">0</td>
  <td style="text-align: center;">0</td>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">...</td>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">...</td>
  <td style="text-align: right;">0</td>
  </tr>
  <tr>
  <td style="text-align: left;">yy</td>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">0</td>
  <td style="text-align: center;">0</td>
  <td style="text-align: center;">...</td>
  <td style="text-align: center;">9</td>
  <td style="text-align: center;">...</td>
  <td style="text-align: right;">0</td>
  </tr>
  <tr>
  <td style="text-align: left;">zz</td>
  <td style="text-align: center;">3</td>
  <td style="text-align: center;">2</td>
  <td style="text-align: center;">1</td>
  <td style="text-align: center;">...</td>
  <td style="text-align: center;">0</td>
  <td style="text-align: center;">...</td>
  <td style="text-align: right;">0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Now, I want to collect the sum of the values of the first 12 variables in another one called, say, &quot;tot_2000&quot; which should contain just one number (in this example it is 18).
  Then, I must repeat this passage for the 3 remaining years, thus having 4 variables (&quot;tot_2000&quot;, &quot;tot_2001&quot;, &quot;tot2002&quot;, &quot;tot2003&quot;) to be plotted in an histogram.</p>
  <p>What I'm looking for is such a variable:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">tot_2000</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">18</td>
  </tr>
  </tbody>
  </table>
  </div>