title: How to store a mean value in a local macro and then save it in another file?
body: <p>I have a Stata file <code>file1.dta</code> and one of the variables is <code>income</code>. I need to calculate <code>average_income</code>, assign it to a local macro, and store in a different Stata file, <code>New.dta</code>.  </p>
  
  <p>I have tried the following in a <code>do</code> file:</p>
  
  <pre><code>#delimit;
  clear;
  set mem 700m;
  
  use file1.dta;
  local average_income = mean income; 
  
  use New.dta;
  gen avincome = average_income;
  </code></pre>
  
  <p>However, it does not work.</p>