I have two unbalanced panel dataset with different variables in different frequencies. The first one has annual data with time periods 1980, 1990, 2000, and 2010, as shown below.
Code:
fipsmerg cntynm stateab year totpop reltrad adherent 1001 Autauga County AL 1980 32259 Protestant 15796 1001 Autauga County AL 1980 32259 Catholic 43 1001 Autauga County AL 1980 32259 Other 200 1001 Autauga County AL 1990 34222 Catholic 1025 1001 Autauga County AL 1990 34222 Protestant 22361 1001 Autauga County AL 1990 34222 Other 323 1001 Autauga County AL 2000 43671 Catholic 1490 1001 Autauga County AL 2000 43671 Other 465 1001 Autauga County AL 2010 54571 Protestant 38480 1001 Autauga County AL 2010 54571 Other 856 1001 Autauga County AL 2010 54571 Catholic 1766 1003 Baldwin County AL 1980 32259 Protestant 19796 1003 Baldwin County AL 1980 32259 Catholic 435 1003 Baldwin County AL 1980 32259 Other 900 1003 Baldwin County AL 1990 34222 Catholic 600 1003 Baldwin County AL 1990 34222 Protestant 29000 1003 Baldwin County AL 1990 34222 Other 300 1003 Baldwin County AL 2000 43671 Catholic 1100 1003 Baldwin County AL 2000 43671 Other 500 1003 Baldwin County AL 2010 54571 Protestant 41000 1003 Baldwin County AL 2010 54571 Other 900 1003 Baldwin County AL 2010 54571 Catholic 1800
The second has annual data, as shown below. This time range is 1975-2015
Code:
gvkey datadate fyear 001004 31may1976 1975 001004 31may1977 1976 001004 31may1978 1977 001004 31may1979 1978 001004 31may1980 1979 001004 31may1981 1980 001004 31may1982 1981 001004 31may1983 1982 001004 31may1984 1983 001004 31may1985 1984 001004 31may1986 1985 001004 31may1987 1986 001004 31may1988 1987 001004 31may1989 1988 001004 31may1990 1989 001004 31may1991 1990 001004 31may1992 1991 001004 31may1993 1992 001004 31may1994 1993 001004 31may1995 1994 001004 31may1996 1995 001004 31may1997 1996 001004 31may1998 1997 001004 31may1999 1998 001004 31may2000 1999 001004 31may2001 2000 001004 31may2002 2001 001004 31may2003 2002
Can someone please help me with the code? I aim for something like the following, which I found here .
Code:
expand 10 bys fipsmerg year: replace totpop=. if _n!=_N by fipsmerg: gen year_new=_n by fipsmerg: ipolate totpop year_new, gen(y_pop) epolate by fipsmerg year: replace year_new=_n
Thanks in advance!
0 Response to interpolate between two decades using expand
Post a Comment