Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: Help Creating a Lagged Variable


From   "Angeli Kirk" <angeli.kirk@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: Help Creating a Lagged Variable
Date   Tue, 12 Sep 2006 16:12:51 -0400

Do you have more than one regime change for any country?

If not, you might try:

gen regimeyear_temp= year*regimechange    [will = 0 if no change that
year or the year if there is a change]
egen regimeyear=max(regimeyear_temp), by(country)
replace regimeyear=1945 if regimeyear==0   [catches all those with no change]

This would also work if you had multiple changes but only needed to
mark year of the last regime change.

Cheers,
Angeli

On 9/12/06, Michael Blasnik <michael.blasnik@verizon.net> wrote:
This may work:

by country: gen regimeyear=year if _n==1 | regimechange==1
by country: replace regimeyear=regimeyear[_n-1] if regimeyear==.

M Blasnik

----- Original Message -----
From: "Michael Horowitz" <horowitz@fas.harvard.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Tuesday, September 12, 2006 2:42 PM
Subject: st: Help Creating a Lagged Variable


> To whom it may concern:
>
> I have data set up in country-year format, where there is one observation
> per country per year.  There is also a regime change variable that is a 0
> if no regime change occurred in that year and a 1 otherwise.  The dataset
> runs from 1945-2002.
>
> I am interested in creating a lagged variable for each country for each
> year that will take on the value of the start year for the dataset if
> no regime change has occurred for that country since the beginning of the
> dataset and the year of the regime change if a regime change has occurred.
<snip>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index