Stata Listers:
I have a general question about where to specify temporary names for local macros inside ado files.
I use Stata version 15.1 and it is fully updated.
For temporary variables in Ado files, Baum gives the very helpful advice (in his book I believe) that the tempvar command can be used anywhere in an ado file, and you can list all the temporary variables that are going to be created in one place.
Does the same rule apply for the temporary names that are applied to local macros inside the Ado file?
Does the tempname command have to come right after the local it refers to is created?
In many of my Ado files, I have the "tempname" command on numerous lines, and they make my program harder to navigate. If I could consolidate them, it would shorten my programs significantly and would help me make fewer mistakes.
I also just want to make sure the local macros inside the Ado file aren't interfering with local macros outside the Ado file if they happen to share the same name.
An admittedly minor issue is the following. When you put the tempname (or tempvar) command inside a loop, as in the following example, a buildup of local macros that might slow computing in an extreme case occurs.
foreach examplelocal of local examplelocal2 {
tempname `examplelocal'
gen `examplelocal'=5
}
Specifying "tempvar" inside a loop resulted in enough temporary variables to cause Stata to stop running, when I didn't know you could specify all the temporary variables at once (and therefore outside the loop).
The bottom line is I just don't like the local macros building up.
Generally, what are best practices for where the "tempname" command should be placed in Ado files?
I've experimented with this and have looked through the documentation, but would still value guidance from experienced Stata users.
Thanks,
Carl
Related Posts with Where to Specify Temporary Names for Local Macros Inside Ado Files
Using -xtile- to assess the impact of a variable on an outcomeHi All, I am looking to understand at what number of kids or distribution does a household member g…
Help Stata SE 16.1 | Structural equation modelingGood morning. I would like to get the same format of result as the picture (Result.PNG). My question…
Error while using _N in forvalues loopI want to use _N in place of the total count of observations in a loop like this: forvalues i = 1(1…
How to use marker symbols with twoway graphDear Statalists, I have two questions that I am sure are relatively easy for you. First: I am plott…
How to make a new variable from a group of variables answered on a rickert scaleHi All, I am using a firm-level data set and I have 11 questions relating to the obstacles to innov…
Subscribe to:
Post Comments (Atom)
0 Response to Where to Specify Temporary Names for Local Macros Inside Ado Files
Post a Comment