title: How to split data and assign it into designated variables?
body: <p>I have data in Stata regarding the feeling of the current situation. There are seven types of feeling. The data is stored in the following format (note that the data type is a string, and one person can respond to more than 1 answer)</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>feeling</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>4,7</td>
  </tr>
  <tr>
  <td>1,3,4</td>
  </tr>
  <tr>
  <td>2,5,6,7</td>
  </tr>
  <tr>
  <td>1,2,3,4,5,6,7</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Since the data is a string, I tried to separate it by</p>
  <pre><code>split feeling, parse (,)
  </code></pre>
  <p>and I got the result</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>feeling1</th>
  <th>feeling2</th>
  <th>feeling3</th>
  <th>feeling4</th>
  <th>feeling5</th>
  <th>feeling6</th>
  <th>feeling7</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>4</td>
  <td>7</td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>1</td>
  <td>3</td>
  <td>4</td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>2</td>
  <td>5</td>
  <td>6</td>
  <td>7</td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>3</td>
  <td>4</td>
  <td>5</td>
  <td>6</td>
  <td>7</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>However, this is not the result I want. which is <strong>that the representative number of feelings should go into the correct variable</strong>.  For instance.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>feeling1</th>
  <th>feeling2</th>
  <th>feeling3</th>
  <th>feeling4</th>
  <th>feeling5</th>
  <th>feeling6</th>
  <th>feeling7</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td></td>
  <td></td>
  <td></td>
  <td>4</td>
  <td></td>
  <td></td>
  <td>7</td>
  </tr>
  <tr>
  <td>1</td>
  <td></td>
  <td>3</td>
  <td>4</td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td></td>
  <td>2</td>
  <td></td>
  <td></td>
  <td>5</td>
  <td>6</td>
  <td>7</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>3</td>
  <td>4</td>
  <td>5</td>
  <td>6</td>
  <td>7</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I am not sure if there is any built-in command or function for this kind of problem. I am thinking about using <code>forval</code> in looping through every value in each variable and try to juggle it around into the correct variable.</p>