Dear users,
I have noticed that if one declares a tempvar, say
tempvar october
and later on assign a variable which can take positive or negative values,
gen `october' = 2*runiform() -1
when one does
gen october2 = ``october'' ^2
the result is the square of the positive numbers and, worryingly, the "negative" of the square of the negative numbers (that is, the sing is preserved). Thus, if `october' = -2, then ``october''^2 = -4. To get the right answer, one seems to have to do
gen october2 = (``october'')^2
So, my question is, has anyone experience this before? Is this a well known Stata trait??????
Thank you.
I have noticed that if one declares a tempvar, say
tempvar october
and later on assign a variable which can take positive or negative values,
gen `october' = 2*runiform() -1
when one does
gen october2 = ``october'' ^2
the result is the square of the positive numbers and, worryingly, the "negative" of the square of the negative numbers (that is, the sing is preserved). Thus, if `october' = -2, then ``october''^2 = -4. To get the right answer, one seems to have to do
gen october2 = (``october'')^2
So, my question is, has anyone experience this before? Is this a well known Stata trait??????
Thank you.
Comment