Dear all,
I am using spell data to capture the event of moving abroad (return).
I provide an exemplary dataset containing some of the variables of interest-see below, the dataset contains variables like spell number, spell begin, spell end. I tried merging the info. from panel data on life satisfaction and I merged it in the wide format of the "ls*" variable so I have it now generated for 1984-2018, this latter is on a scale from 0 to 10 where 0 is the minimum and 10 is the maximum current life satisfaction estimated at each survey year. In the example data, I only contained ls1984 & ls1985 but this should be there for every year until 2018. Actualreturn is a binary variable if attrition==moved abroad, spelltyp==2 means if they participated in the survey directly before moving abroad
I'd like to test the effect of current life satisfaction (ls) expressed in the lagged year of departure on actual return probability. I assume the begin of "moving abroad" spell reflects the year of emigration. Thus, I need to generate a variable for life satisfaction one year before emigration, something that yields; lagged_ls=ls(begin-1). So, I can test the effect of this lagged_ls on actualreturn.
-------
I am using spell data to capture the event of moving abroad (return).
I provide an exemplary dataset containing some of the variables of interest-see below, the dataset contains variables like spell number, spell begin, spell end. I tried merging the info. from panel data on life satisfaction and I merged it in the wide format of the "ls*" variable so I have it now generated for 1984-2018, this latter is on a scale from 0 to 10 where 0 is the minimum and 10 is the maximum current life satisfaction estimated at each survey year. In the example data, I only contained ls1984 & ls1985 but this should be there for every year until 2018. Actualreturn is a binary variable if attrition==moved abroad, spelltyp==2 means if they participated in the survey directly before moving abroad
Code:
gen attrition = spelltyp if spelltyp[_n-1] == 2 & pid == pid[_n-1]
-------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id actualreturn) long spellnr int(begin end) float attrition byte(ls1984 ls1985) 12127 1 3 1988 1988 3 5 0 12128 1 3 1988 1988 3 1 0 12136 1 3 2000 2000 3 8 8 12137 1 3 2000 2000 3 9 8 12138 1 3 1989 1989 3 10 8 12139 1 3 1985 1985 3 10 . 12145 1 3 2008 2008 3 7 8 12146 1 3 2008 2008 3 7 8 12153 1 2 2000 2000 3 10 10 12164 1 3 1994 1994 3 8 7 end label values attrition spelltyp label def spelltyp 3 "[3] Living Abroad", modify label values ls1984 plh0182 label values ls1985 plh0182 label def plh0182 1 "[1] 1 Zufrieden: Skala 0-Niedrig bis 10-Hoch", modify label def plh0182 5 "[5] 5 Zufrieden: Skala 0-Niedrig bis 10-Hoch", modify label def plh0182 7 "[7] 7 Zufrieden: Skala 0-Niedrig bis 10-Hoch", modify label def plh0182 8 "[8] 8 Zufrieden: Skala 0-Niedrig bis 10-Hoch", modify label def plh0182 9 "[9] 9 Zufrieden: Skala 0-Niedrig bis 10-Hoch", modify label def plh0182 10 "[10] 10 Zufrieden: Skala 0-Niedrig bis 10-Hoch", modify label def plh0182 0 "[0] 0 Zufrieden: Skala 0-Niedrig bis 10-Hoch", modify
Comment