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
Fractional polynomials and nonlinear least-squares estimationIs there a fundamental reason why fractional polynomials (either -fp- or -mfp-) are not allowed when…
non parametric regression discontinuity with interaction termi am writing to ask if is it possible to do a non parametric regression discontinuity with an intera…
Problem regarding imputation of missing valueHii I am working on self reported cross section data set. Most of the variable are ordinal in nature…
Diagnostic tests for correlated random effects modelHi, What diagnostic tests can be done on a correlated random effects model? And if so how do I code…
Fixed effect xtreg - Panel data - P-valueHey everyone, I'm trying to find the regression of my panel dataset. I'm trying to calculate the re…
Subscribe to:
Post Comments (Atom)
0 Response to Where to Specify Temporary Names for Local Macros Inside Ado Files
Post a Comment