Hi All,
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.
The second has annual data, as shown below. This time range is 1975-2015
I first aim to generate years between the decades (linearly interpolate), such that i can merge it with the second dataset.
Can someone please help me with the code? I aim for something like the following, which I found here .
Yet, i need interpolated years, totpop, and adherent, rather than only totpop as is in the code above.
Thanks in advance!
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:
* Example generated by -dataex-. For more info, type help dataex clear input long fipsmerg int year long totpop float reltrad double adherent 1001 1980 32259 1 15796 1001 1980 32259 3 43 1001 1980 32259 4 200 1001 1990 34222 3 1025 1001 1990 34222 1 22361 1001 1990 34222 4 323 1001 2000 43671 3 1490 1001 2000 43671 4 465 1001 2000 43671 1 26476 1001 2010 54571 1 38480 1001 2010 54571 4 856 1001 2010 54571 3 1766 end label values reltrad reltrad label def reltrad 1 "Protestant", modify label def reltrad 3 "Catholic", modify label def reltrad 4 "Other", modify
The second has annual data, as shown below. This time range is 1975-2015
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str6 gvkey double fyear "001001" 1983 "001001" 1984 "001001" 1985 "001003" 1982 "001003" 1983 "001003" 1984 "001003" 1985 "001003" 1986 "001003" 1987 "001003" 1988 "001003" 1989 "001004" 1975 "001004" 1976 "001004" 1977 "001004" 1978 "001004" 1979 "001004" 1980 "001004" 1981 "001004" 1982 "001004" 1983 end
I first aim to generate years between the decades (linearly interpolate), such that i can merge it with the second dataset.
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!
Comment