Q:

Reuse lines of code in Stata, Similar to JavaScript function?

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.
For example, I have some code:
*code to reuse
foreach x in test1 test2 test3{
rename variable_`x' variablenew_`x'
}

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 codeA and then execute codeA later in the do file.
Any suggestions?

A:

Check help program. 
An example program (that takes no arguments):
// define program
capture program drop hello
program hello
    display "hello world!"
end

// try it out
hello

