Landman, Todd
> I have two separate questions:
>
> (1) I have a treaty ratification variable that is coded as
> follows for the period 1976-2000:
>
> 0 = no signature
> 1 = signature
> 2 = ratification
>
> How would I create a new variable that sums the years since
> full ratification, i.e. the total number of years from when
> the variable assumes a value of 2.
I guess that your data look like this:
treaty year ratification
====== ==== ============
A 1976 0
A 1977 1
...
A 1986 2
...
A 2000 2
B 1976 0
etc.
Here is one way.
gen year1 = year if rat == 2
egen year2 = min(year1), by(treaty)
gen year3 = year - year2
Another approach is to use -tsspell-
from SSC.
tsset treaty year
tsspell, fcond(rat == 2)
The variables created automatically
include _seq, which should be close
to what you what (subtract 1?).
Nick
[email protected]
*
* 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/