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

st: RE: RE: Creating a time from event variable


From   "Landman, Todd" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Creating a time from event variable
Date   Thu, 10 Jul 2003 09:25:32 +0100

The data look as follows:

Country year treaty
======= ==== ======
A       1976	0
A       1977	1
A       1978      1
.
.
.
A       1985      2
A       1986      2

etc.

So, would the code you specify below still apply?

Todd

-----Original Message-----
From: Nick Cox [mailto:[email protected]]
Sent: 09 July 2003 17:28
To: [email protected]
Subject: st: RE: Creating a time from event variable


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/

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