Dear Statalisters,
Before I bother the technical support of StataCorp, I would like to hear your opinion about the following behavior of fvrevar.
When I call fvrevar once with a variable name that contains time-series operators, it creates a new temporary variable with the same values as the original. This is expected.
When I subsequently call fvrevar again with the same original variable name, it does not create a new temporary variable but instead returns the name of the previously created temporary variable. This becomes problematic when I modify the content of this temporary variable before calling fvrevar the second time, or simply when I need two different temporary variables for subsequent computations.
Here is an example:
The output is as follows:
I expected that the second call of fvrevar would create a new temporary variable _000001 with the values of the original variable L.n, not again _000000, because I want to do different things with the two temporary variables.
I would call this a bug, but maybe there is a reason for this behavior that I do not see?!
Before I bother the technical support of StataCorp, I would like to hear your opinion about the following behavior of fvrevar.
When I call fvrevar once with a variable name that contains time-series operators, it creates a new temporary variable with the same values as the original. This is expected.
When I subsequently call fvrevar again with the same original variable name, it does not create a new temporary variable but instead returns the name of the previously created temporary variable. This becomes problematic when I modify the content of this temporary variable before calling fvrevar the second time, or simply when I need two different temporary variables for subsequent computations.
Here is an example:
Code:
clear all webuse abdata program fvrevar_test syntax varname(num ts) // varlist refers to variable L.n // fvrevar creates temporary variable __000000 identical to L.n fvrevar `varlist' loc newvarname "`r(varlist)'" sum `varlist' `newvarname' // content of only the temporary variable __000000 is modified replace `newvarname' = 0 // varlist still refers to original unchanged variable L.n // fvrevar attempts again to create the temporary variable __000000 (instead of __000001) // "new" temporary variable has the same values as the previously modified temporary variable (bug?) fvrevar `varlist' loc newvarname "`r(varlist)'" sum `varlist' `newvarname' end fvrevar_test L.n
Code:
. fvrevar_test L.n Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- n | L1. | 891 1.083518 1.338469 -2.095571 4.687321 | __000000 | 891 1.083518 1.338469 -2.095571 4.687321 (1,031 real changes made) Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- n | L1. | 891 1.083518 1.338469 -2.095571 4.687321 | __000000 | 1,031 0 0 0 0
I would call this a bug, but maybe there is a reason for this behavior that I do not see?!
Comment