Dear all, I am asked this question. The data set is
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id year x y)
1 2011 . 5
1 2012 5 5
1 2013 . 3
1 2014 7 1
1 2015 1 5
2 2011 1 .
2 2012 . 4
2 2013 2 1
2 2014 8 .
2 2015 4 3
3 2011 2 5
3 2012 5 4
3 2013 . 1
3 2014 5 .
3 2015 . 5
end
For each id, if the value of y (do not include missing values) appears in the x (in all years), then a dummy (say, dum) is equal to 1, 0 otherwise. For instance, id=1, year=2011, y=5, which is equal to x=5 in year 2012, then dum=1. Of course, it is clear that dum=1 when id=1 and year=2012. Similarly, id=1, year=2014, y=1 and is equal to x=1 in year 2015. Thus dum=1. Any suggestions?