Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: local variable holdovers


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: local variable holdovers
Date   Thu, 9 Dec 2004 16:33:50 -0500

Phiilip said

gen UBAR = `TOT_CASES'[_N]/`TOT_POPN'[_N]

but he meant to say

gen `UBAR' = `TOT_CASES'[_N]/`TOT_POPN'[_N]

He is creating a non-temp-var UBAR when he means to create a tempvar UBAR. Seems like the same problem arises for any of these tempvars in his code.

Unlike local foo = whatever, in which foo is not "tiicked" when it appears on the LHS, once something is a tempvar or a tempname, any ref to it should be via the "ticked" form `foo'.

. sysuse auto
(1978 Automobile Data)

. tempvar junk

. g junk = price/mpg

. su `junk'
variable __000000 not found
r(111);

. g `junk' = price^2

. su `junk'

Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
__000000 | 74 4.66e+07 5.14e+07 1.08e+07 2.53e+08

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index