*install synth package, import data and then: encode country, gen(ncountry) egen dateid = group(qdate) egen countryid = group(ncountry) generate UK = (countryid == 22) tsset ncountry dateid synth realgdp realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(31) mspeperiod(15(1)30) nested keep(prereftrainingOECDrealgdp2016Fetzer, replace) fig graph save Graph prereftrainingOECDrealgdp2016Fetzer, replace save basedataset, replace gsample 50 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth realgdp realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(31) mspeperiod(15(1)30) nested keep(prereftrainingOECDrealgdp2016Fetzer50pc, replace) fig clear use basedataset gsample 20 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth realgdp realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(31) mspeperiod(15(1)30) nested keep(prereftrainingOECDrealgdp2016Fetzer20pc, replace) fig clear use basedataset gsample 30 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth realgdp realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(31) mspeperiod(15(1)30) nested keep(prereftrainingOECDrealgdp2016Fetzer30pc, replace) fig clear use basedataset gsample 40 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth realgdp realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(31) mspeperiod(15(1)30) nested keep(prereftrainingOECDrealgdp2016Fetzer40pc, replace) fig clear use basedataset gsample 60 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth realgdp realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(31) mspeperiod(15(1)30) nested keep(prereftrainingOECDrealgdp2016Fetzer60pc, replace) fig clear use basedataset gsample 70 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth realgdp realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(31) mspeperiod(15(1)30) nested keep(prereftrainingOECDrealgdp2016Fetzer70pc, replace) fig clear use basedataset gsample 80 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth realgdp realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(31) mspeperiod(15(1)30) nested keep(prereftrainingOECDrealgdp2016Fetzer80pc, replace) fig clear use basedataset gsample 90 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth realgdp realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(31) mspeperiod(15(1)30) nested keep(prereftrainingOECDrealgdp2016Fetzer90pc, replace) fig use prereftrainingOECDrealgdp2016Fetzer50pc, clear rename _Y_synthetic fifty_pc merge 1:m _time using prereftrainingOECDrealgdp2016Fetzer20pc rename _Y_synthetic twenty_pc drop _merge merge 1:m _time using prereftrainingOECDrealgdp2016Fetzer30pc rename _Y_synthetic thirty_pc drop _merge merge 1:m _time using prereftrainingOECDrealgdp2016Fetzer40pc rename _Y_synthetic forty_pc drop _merge merge 1:m _time using prereftrainingOECDrealgdp2016Fetzer60pc rename _Y_synthetic sixty_pc drop _merge merge 1:m _time using prereftrainingOECDrealgdp2016Fetzer70pc rename _Y_synthetic seventy_pc drop _merge merge 1:m _time using prereftrainingOECDrealgdp2016Fetzer80pc rename _Y_synthetic eighty_pc drop _merge merge 1:m _time using prereftrainingOECDrealgdp2016Fetzer90pc rename _Y_synthetic ninety_pc drop _merge merge 1:m _time using prereftrainingOECDrealgdp2016Fetzer rename _Y_synthetic hundred_pc drop _merge gen average_Y_synthetic = (twenty_pc + thirty_pc + forty_pc + fifty_pc + sixty_pc + seventy_pc + eighty_pc + ninety_pc + hundred_pc)/9 twoway (line _Y_treated _time) (line average_Y_synthetic _time) gen UKloss = 100-((100 + _Y_treated) / (100 + average_Y_synthetic) * 100) graph save Graph prereftrainingOECDrealgdp016Fetzeraverage, replace save prereftrainingOECDrealgdp2016Fetzeraverage, replace