title: Reuse lines of code in Stata, Similar to JavaScript function?
body: <p>I have some lines of code in a Stata do-file that I would like to reuse/execute and different points in the do file. Similar to a JavaScript function... however I do not necessarily need an input variable.</p>
  
  <p>For example, I have some code:</p>
  
  <pre><code>*code to reuse
  foreach x in test1 test2 test3{
  rename variable_`x' variablenew_`x'
  }
  </code></pre>
  
  <p>and I want to execute those 3 lines of code at various points in the do file. As if there was a way to label those three lines <code>codeA</code> and then <code>execute codeA</code> later in the do file.</p>
  
  <p>Any suggestions?</p>