Dear all,
I would like check whether I can overwrite the missing deprivation variable (dep) with the value of the previous year. To check whether that does not create a bias I wanted to generate 2 change variables (1 for dep and 1 for income_cat) and compare the two. Deprivation is a dummy and income_cat is categorized like this:

gen income_cat = .
replace income_cat = 5 if equivincome > median_inc*1.5 /*wohlhabende*/
replace income_cat = 4 if equivincome > median_inc & equivincome <= median_inc*1.5 /*höhere mittlere Eink*/
replace income_cat = 3 if equivincome > median_inc*0.8 & equivincome <= median_inc /*mittlere Eink*/
replace income_cat = 2 if equivincome > median_inc*0.6 & equivincome <=median_inc*0.8 /*prekäre Einkommen */
replace income_cat = 1 if equivincome < median_inc*0.6


Since I am not very advanced in Stata, I tried it with the following code for the age span 2001 to 2003 for deprivation, but the 3rd variable saved 0 changes...:

gen dep_2001 = .
replace dep_2001 = 0 if dep == 0 & syear == 2001
replace dep_2001 = 1 if dep == 1 & syear == 2001

gen dep_2003 = .
replace dep_2003 = 0 if dep == 0 & syear == 2003
replace dep_2003 = 1 if dep == 1 & syear == 2003

gen dep_0103 = .
replace dep_0103 = 0 if dep_2001 == 0 & dep_2003 == 0
replace dep_0103 = 1 if dep_2001 == 0 & dep_2003 == 1
replace dep_0103 = 2 if dep_2001 == 1 & dep_2003 == 0
replace dep_0103 = 3 if dep_2001 == 1 & dep_2003 == 1


This is the Code (I would also consider going a percentage change of equiv income)


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long pid int syear float(dep income_cat equivincome)
 201 2000 . 1      8510
 201 2001 0 1      8858
 201 2002 . 1      1627
 201 2003 0 1      7287
 201 2004 . 3     15185
 201 2005 0 1      7648
 201 2006 . 1      7723
 201 2007 1 2     11488
 201 2008 . 1      8673
 203 2000 . 4     21212
 203 2001 0 4     21281
 203 2002 . 4     25398
 203 2003 0 4     27242
 203 2004 . 4     26525
 203 2005 0 4     18800
 203 2006 . 4     24796
 203 2007 0 4     23217
 203 2008 . 4     23828
 601 2000 . 5  91799.43
 601 2001 0 5  74910.89
 601 2002 . 5  93241.23
 601 2003 0 5  54433.08
 602 2000 . 4     20017
 602 2001 0 4     23594
 602 2002 . 4   23485.5
 602 2003 0 4     22628
 602 2004 . 4     21356
 602 2005 0 4   23876.5
 602 2006 . 5     28357
 602 2007 0 4     24080
 602 2008 . 4   22833.5
 602 2009 . 4     23930
 602 2010 . 4     28200
 602 2011 0 4  25488.86
 602 2012 . 4  21948.55
 604 2007 0 4     24080
 604 2008 . 4   22833.5
 604 2009 . 4     23930
 901 2000 . 3     14350
 901 2001 1 3     14639
 901 2002 . 2     13826
 901 2003 0 2     12504
 901 2004 . 2     14333
 901 2005 1 3     15005
 901 2006 . 3     15071
 901 2007 0 2     14646
 901 2008 . 2     12071
 901 2009 . 2     15222
 901 2010 . 2     15304
 901 2011 0 2     15318
 901 2012 . 2     15066
 901 2013 0 2     15286
 901 2014 . 2     15391
 901 2015 0 2     15355
1202 2000 . 4     18975
1202 2001 0 4     17747
1202 2002 . 4     18806
1501 2000 . 5     55871
1501 2001 0 5     61132
1501 2002 . 5     65084
1501 2003 0 5     54261
1501 2004 . 5     44876
1501 2005 0 5     57810
1501 2006 . 5     58957
1501 2007 0 5     57192
1501 2008 . 5     60712
1501 2009 . 5     50571
1501 2010 . 5     50612
1501 2011 0 5     59658
1501 2012 . 5    120497
1501 2013 0 5     54516
1501 2014 . 5     58659
1501 2015 0 5     58773
1501 2016 0 5     55184
1601 2000 . 1      9079
1601 2001 0 1  6803.496
1601 2002 . 3  14995.52
1601 2003 1 2  11436.73
1601 2004 . 2 14175.104
1601 2005 0 2  12105.88
1601 2006 . 2 14666.102
1601 2007 1 2 14785.604
1601 2008 . 3 15809.494
1601 2009 . 2  14444.07
1601 2010 . 2 13095.618
1602 2001 0 1  6803.496
1602 2002 . 3  14995.52
1602 2003 1 2  11436.73
1602 2004 . 2 14175.104
1602 2005 0 2  12105.88
1602 2006 . 2 14666.102
1602 2007 1 2 14785.604
1602 2008 . 3 15809.494
1602 2009 . 2  14444.07
1603 2003 1 2  11436.73
1603 2004 . 2 14175.104
1603 2005 0 2  12105.88
1701 2000 . 5  25680.54
1701 2001 0 4 25965.174
1701 2002 . 5 27537.877
end


Any assistance will be immensely appreciated