title: Tabulate multiple variables with common prefix using a local macro
body: <p>I have a number of variables whose name begins with the prefix <code>indoor</code>. What comes after <code>indoor</code> is not numeric (that would make everything simpler). </p>
  
  <p>I would like a tabulation for each of these variables. </p>
  
  <p>My code is the following:</p>
  
  <pre><code>local indoor indoor*  
  foreach i of local indoor {  
      tab `i' group, col freq exact chi2  
  }
  </code></pre>
  
  <p>The problem is that <code>indoor</code> in the <code>foreach</code> command resolves to <code>indoor*</code> and not to the list of the <code>indoor</code> questions, as I hoped. For this reason, the <code>tab</code> command is followed by too many variables (it can only handle two) and this results in an error.</p>
  
  <p>The simple fix is to substitute the first command with:</p>
  
  <pre><code>local indoor &lt;full list of indoor questions&gt;
  </code></pre>
  
  <p>But this is what I would like to avoid, that is to have to find all the names for these variables and then paste them in the code. It seems there is a quicker fix for this but I can't think of any.</p>