Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: shifting status variable


From   Nick Sanders <sandersn@stanford.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: shifting status variable
Date   Fri, 19 Nov 2010 09:03:40 -0800

In this case, though, you'll want to avoid it that. I assume the variable is "1" any time an observation is "divorced". Since you don't have info from before the first year of the record, you can't tell if that person changed status in the first year or has been divorced for some time. Using the " | _n ==1" qualifier here would make everyone who was divorced in the first year of data be identified as a switcher, even if they'd been divorced for years (just not observed).

--
Nicholas J. Sanders, Ph.D.
Postdoctoral Fellow
Stanford Institute for Economic Policy Research
366 Galvez St, Room 228
Stanford, CA 94305

On Nov 19, 2010, at 8:55 AM, Nick Cox wrote:

> There is at least one small refinement here. Suppose someone got divorced in the first year of record. Then for that observation -separati- is 1 but -separati[_n-1]- evaluates to missing. Thus the condition for divorced this year should be 
> 
> separati == 1   &     separati[_n-1] == 0 | _n == 1
> 
> where the extra possibility _n == 1, under the aegis of -by:-, identifies the first observation of record. 
> 
> More general technique is discussed in 
> 
> SJ-7-2  dm0029  . . . . . . . . . . . . . . Speaking Stata: Identifying spells
>        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
>        Q2/07   SJ 7(2):249--265                                 (no commands)
>        shows how to handle spells with complete control over
>        spell specification
> 
> and (independently) encoded within -tsspell- from SSC. Either of these two sources could be of use if interest extends to e.g. lengths of time spent divorced. 
> 
> Nick 
> n.j.cox@durham.ac.uk 
> 
> Nick Sanders
> 
> This is a bit clunky, but it should do the trick (I imagine someone else has a cleaner way out there). Note this can't identify those who divorced in 2004, but you can't do that with your data anyway.
> 
> *Sort into individual/year order
> sort pb030 pb010
> 
> *Generate indicator for "Changed status this year"
> by pb030: gen divorced = (separati == 1 & separati[_n-1] == 0)
> 
> *Generate indicators for divorced in difference years
> foreach year in 2005 2006 2007 {
> 	gen divorced_`year'  = (divorced == 1 & pb010 == `year')
> }
> 
> That should do it (assuming you have no missing data)
> 
> On Nov 18, 2010, at 11:23 AM, Vincenzo Carrieri wrote:
> 
>> I would like to create a dummy variable equals to one for persons
>> which decide to divorce in a given year.
>> I have a panel data with the following key variables:
>> 
>> pb010=year variable (2004, 2005, 2006, 2007)
>> separati=dummy variable equal to one for divorced persons (marital
>> status=divorced)
>> pb030=personal id
>> 
>> My question is: How is it possible to create a variable which takes
>> the value one if the person changes his marital status (from married
>> to divorced) in the year 2005 (with respect to 2004), 2006 (with
>> respect to 2005) and 2007 (with respect to 2006)?
>> 
>> My final concern is to build 3 variables: people divorced in 2005,
>> people divorced in 2006 and people divorced in 2007.
>> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index