Hi Everyone!
I have a dataset looks like the below. I wanna replace missing values withing "locale" with the first valid value in "locale", while the data are sorted by "endyear" and "unitid". I tried the following command buy it did not work. I appreciate your advice.
Best,
Nader
bysort unitid endyear: replace locale = locale[n+1] if locale==.
Endyear-unitid-locale
2000-1-.
2001-1-.
2002-1-2
2003-1-3
2000-2-.
2001-2-.
2002-2-9
2000-3-5
2001-3-.
2002-3-6
I would like to get the following:
Endyear-unitid-locale
2000-1-2
2001-1-2
2002-1-2
2003-1-3
2000-2-9
2001-2-9
2002-2-9
2000-3-5
2001-3-6
2002-3-6
I have a dataset looks like the below. I wanna replace missing values withing "locale" with the first valid value in "locale", while the data are sorted by "endyear" and "unitid". I tried the following command buy it did not work. I appreciate your advice.
Best,
Nader
bysort unitid endyear: replace locale = locale[n+1] if locale==.
Endyear-unitid-locale
2000-1-.
2001-1-.
2002-1-2
2003-1-3
2000-2-.
2001-2-.
2002-2-9
2000-3-5
2001-3-.
2002-3-6
I would like to get the following:
Endyear-unitid-locale
2000-1-2
2001-1-2
2002-1-2
2003-1-3
2000-2-9
2001-2-9
2002-2-9
2000-3-5
2001-3-6
2002-3-6
Comment