Hi everyone,

I have missing values in the variable "religion" for the year 2009. I want to copy the value of religion from the year 2007 using household id. This seems like an easy thing but I just can't figure out the right code. Any help will be highly appreciated.

Similar household ids represent members of the same household and the number of members in a given household may change within as well over years.


Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input byte religion double hhid int year
2 81216 2007
. 81216 2009
. 81216 2009
. 81216 2009
. 81216 2009
. 81216 2009
. 81216 2009
2 81226 2007
2 81226 2007
2 81226 2007
2 81226 2007
. 81226 2009
. 81226 2009
. 81226 2009
. 81226 2009
2 81231 2007
. 81231 2009
2 81233 2007
2 81233 2007
2 81233 2007
. 81233 2009
. 81233 2009
. 81233 2009
2 81238 2007
2 81238 2007
2 81238 2007
. 81238 2009
. 81238 2009
. 81238 2009
. 81238 2009
2 81246 2007
2 81246 2007
2 81246 2007
2 81246 2007
2 81246 2007
. 81246 2009
. 81246 2009
. 81246 2009
. 81246 2009
. 81246 2009
2 81249 2007
2 81249 2007
2 81249 2007
. 81249 2009
. 81249 2009
. 81249 2009
2 81252 2007
2 81252 2007
. 81252 2009
. 81252 2009
end
label values religion rel
label def rel 2 "Hinduism", modify