Hello,
I am new to this forum and I am currently writing my bachelor's thesis in international economics.
In my research I am using data from 1950 to 2018 which I averaged to 5-year periodes. I used the collapse (mean) command for that.
However, I want to use the initial GDP as a lagged variable. I would like to use for every period the initial GDP from the last year of the previous period, not the averaged initial GDP of the previous period. For example in period 1960-1964 I want to use as intital GDP the GDP from 1959.
Could someone help me? Thank you very much!
These are the commands I used:
gen period = 5 * floor(year/5)
order Country year period
collapse (mean) GDP Trade Inflation GCF Pop_G FDI HC GDP_L1, by (period Country)
gen year = period
order Country period year
sort Country period
replace year = 1 if period==1950
replace year = 2 if period==1955
replace year = 3 if period==1960
replace year = 4 if period==1965
replace year = 5 if period==1970
replace year = 6 if period==1975
replace year = 7 if period==1980
replace year = 8 if period==1985
replace year = 10 if period==1990
replace year = 11 if period==1995
replace year = 12 if period==2000
replace year = 13 if period==2005
replace year = 14 if period==2010
replace year = 15 if period==2015
label var year "5-yr period"
label define fiveyr 1 "1950-54" 2 "1955-59" 3 "1960-64" 4 "1965-69" ///
5 "1970-74" 6 "1975-79" 7 "1980-84" 8 "1985-89" 9 "1990-94" ///
10 "1995-99" 11 "2000-04" 12 "2005-09" 13 "2010-2014" 14 "2015-18"
label value year fiveyr
Related Posts with 5-year average data and lagged variable
Combining datesHey, I have the following dataset: Code: * Example generated by -dataex-. To install: ssc install…
Entropy Balancing in Panel Data SettingHi everyone, I want like to quantify a treatment effect in a model by measuring the differential eff…
winsorizeDearall Thank you for everything Please, can someone tell me what is the correct command for the pan…
question about sem in stataHello I am working on mediation effect using stata SEM. My indepedent variable is binary which answ…
preparing summary statistics tablehello community members, I have panel data for 6 years and have 54 variables in it. I want to prepar…
Subscribe to:
Post Comments (Atom)
0 Response to 5-year average data and lagged variable
Post a Comment