title: How to separate Stata macro `varlist' with commas for using in mi( ) and inlist( )?
body: <p>I want to store a list of variables in a macro and then call that macro inside a <code>mi()</code> statement. The original application is for a programme that uses data I cannot bring online for secrecy reasons, and which will include the following statement: </p>
  
  <pre><code>generate u = cond(mi(`vars'),., runiform(0,1))
  </code></pre>
  
  <p>The issue being that <code>mi()</code> requires comma separated variable names but <code>vars</code> is delimited by spaces.</p>
  
  <p>I use the <code>auto</code> dataset and <code>mark</code> to illustrate my problem:</p>
  
  <pre><code>sysuse auto
  local myvars foreign price
  mark missing if mi(`myvars')
  </code></pre>
  
  <p>In this example, <code>mi()</code> asks for arguments separated by commas, Stata stops and complains that it cannot find a <code>foreignprice</code> variable. Is there a utility function that will insert the commas between the macro elements?</p>