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

st: generating a 0,1 variable which depends on lag values


From   Christopher F Baum <[email protected]>
To   StataList <[email protected]>
Subject   st: generating a 0,1 variable which depends on lag values
Date   Wed, 11 Sep 2002 21:16:03 -0500

The solution to this issue presumably should involve a lag -- that is, "some positive action has been taken by an industry in the previous years." That would mean that Nisha's BB should not be contemporaneously 1, but should become 1 in the following year. A way to do that, starting with the year/industry/actions:

encode industry,gen(ind)
tsset ind year
bys ind: g sum=sum(actions)
g bb=L.sum>0 & L.sum<.

alternatively the last line could be written

g bb=L.sum>0 if L.sum<.

which would make bb missing in the first year of every firm. SInce bb refers to actions taken in prior years, perhaps that is more appropriate.

Kit

*
* 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