Hi to everyone, I need to create a 5-years non-overlapping panel database starting from an usual panel database. I have data from 1970 to 2015 and I need just one observation for 5 years to reduce the effect of missing data. I want to subtract from the last one observation the first observation and divide by 5 and repeat this procedure on all the data by id. But there is a problem of missing data, thus sometimes the 5-years period is reduced for examples to 3-years period. For example:
year id GDP
1970 1 -
1971 1 -
1972 1 1500
1973 1 1700
1974 1 2000
1975 1 1800
1976 1 1900
1977 1 2000
1978 1 2100
1979 1 2000
1970 2 -
1971 2 -
1972 2 -
1973 2 1700
1974 2 2000
1975 2 1800
1976 2 1900
1977 2 2000
1978 2 2100
1979 2 2000
for id 1
first period: 1970-1974 I need to calculate (GDP74-GDP72)/3 since I have missing data
second period: 1975-1979 I need to calculate (GDP79-GDP75)/5 since no missing.
for id 2
first period: 1970-1974 I need to calculate (GDP74-GDP73)/2 since I have missing data
second period: 1975-1979 I need to calculate (GDP79-GDP75)/5 since no missing.
and so on.
How can I say this to STATA? Thank you!
year id GDP
1970 1 -
1971 1 -
1972 1 1500
1973 1 1700
1974 1 2000
1975 1 1800
1976 1 1900
1977 1 2000
1978 1 2100
1979 1 2000
1970 2 -
1971 2 -
1972 2 -
1973 2 1700
1974 2 2000
1975 2 1800
1976 2 1900
1977 2 2000
1978 2 2100
1979 2 2000
for id 1
first period: 1970-1974 I need to calculate (GDP74-GDP72)/3 since I have missing data
second period: 1975-1979 I need to calculate (GDP79-GDP75)/5 since no missing.
for id 2
first period: 1970-1974 I need to calculate (GDP74-GDP73)/2 since I have missing data
second period: 1975-1979 I need to calculate (GDP79-GDP75)/5 since no missing.
and so on.
How can I say this to STATA? Thank you!
Comment