Hi All,
This is my first post, so excuse me breaking any rules/conventions.
I'm trying to generate a set of variables from German migration data.
I am using a panel data set of East Germans (obs. from 1990-2016) where I have a dummy variable (varname = east) for the region the person currently lives in, taking values 1 (East Germany) and 0 (West Germany).
1.) I successfully created an emigrate dummy, which =1 if the individual migrated to West Germany in the last year.
2.) I successfully created a remigrate dummy, which =1 if the individual returned to East Germany in the last year.
3.) I want to create a returner dummy, which =1 if the individual has returned in the past. I failed to do so, this is my code:
gen return = 0
replace return = 1 if east==1 & (l.east==0| l2.east==0| l3.east==0| l4.east==0|l5.east==0| l6.east==0| l7.east==0| l8.east==0| l9.east==0| l10.east==0|l11.east==0| l12.east==0 | l13.east==0| l14.east==0| l15.east==0| l16.east==0|l17.east==0| l18.east==0| l19.east==0| l20.east==0| l21.east==0| l22.east==0|l23.east==0| l24.east==0| l25.east==0 | l26.east==0 | l27.east==0)
---- Logic: Two ifs, 1.) lives in East-Germany 2.) has lived in west-germany in the past, using lags
This doesn't work however, it seems to pick up people that never lived in West Germany
4.) I want to create a returner-to-be variable, which=1 if the individual will return in the future, but has not done so yet (still lives in East or West)
gen returnfuture = 0
replace returnfuture = 1 if (return==0 & (f.remigrate==1 | f2.remigrate==1 | f3.remigrate==1 | f4.remigrate==1 | f5.remigrate==1 | f6.remigrate==1 | f7.remigrate==1 | f8.remigrate==1 f9.remigrate==1 | f10.remigrate==1 | f11.remigrate==1 | f12.remigrate==1 | f13.remigrate==1 | f14.remigrate==1 | f15.remigrate==1 | f16.remigrate==1 | f17.remigrate==1 | f18.remigrate==1 | f19.remigrate==1 | f20.remigrate==1 | f21.remigrate==1 | f22.remigrate==1 | f23.remigrate==1 | f24.remigrate==1 | f25.remigrate==1 | f26.remigrate==1 | f27.remigrate==1 ))
----Same logic, but I need the return variable first, and I'm not sure if this is itself correct.
I would very much appreciate your help on point 3.) and 4.), thank you.
Guus
Related Posts with Generating variables in migration panels
Creating an Abortion scaleHello Everyone, I am trying to create a 7-point scale for attitudes towards abortion for every dec…
assign variable label to variable nameHi I have a dataset that has some variables, say, X1-X10. The corresponding variable labels are 2018…
Create new variables using two categorical variablesI have three variables gender sector and wf. Gender and sector are categorical variables, where gend…
how to calculate output of r(alpha) (short example included)?My deepest apologies if this is difficult to work with. I'm not a stata user, i'm just trying to dec…
What should I do to achieve the following result.? Code: * Example generated by -dataex-. For more info, type help dataex clear input str3 code str29 …
Subscribe to:
Post Comments (Atom)
0 Response to Generating variables in migration panels
Post a Comment