I am trying to define a program (call it prog_b) inside another program (call it prog_a). Something like this:
program define prog_a
program define prog_b
[commands I want prog_b to execute]
end
end
The reason is that I need to use prog_b in a forvalues loop and I need it to function slightly differently in each loop, so in each loop I want to run prog_a to redefine prog_b so that in each loop I can use the appropriately modified version of prog_b for that loop.
The problem is that when I run the code above, in order to define the two functions, I get an error message that says "command end is unrecognized."
program define prog_a
program define prog_b
[commands I want prog_b to execute]
end
end
The reason is that I need to use prog_b in a forvalues loop and I need it to function slightly differently in each loop, so in each loop I want to run prog_a to redefine prog_b so that in each loop I can use the appropriately modified version of prog_b for that loop.
The problem is that when I run the code above, in order to define the two functions, I get an error message that says "command end is unrecognized."
Comment