*install synth package, import data and then: encode country, gen(ncountry) egen dateid = group(date) egen countryid = group(ncountry) generate UK = (countryid == 22) tsset ncountry dateid synth goodstrade goodstrade realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(49) mspeperiod(22(1)43) nested keep(prereftrainingOECDgt2016Fetzer, replace) fig graph save Graph prereftrainingOECDgt2016Fetzer, replace save basedataset, replace gsample 50 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth goodstrade goodstrade realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(49) mspeperiod(22(1)43) nested keep(prereftrainingOECDgt2016Fetzer50pc, replace) fig clear use basedataset gsample 20 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth goodstrade goodstrade realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(49) mspeperiod(22(1)43) nested keep(prereftrainingOECDgt2016Fetzer20pc, replace) fig clear use basedataset gsample 30 if UK==0, percent cluster(countryid) wor keep synth goodstrade goodstrade realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(49) mspeperiod(22(1)43) nested keep(prereftrainingOECDgt2016Fetzer30pc, replace) fig clear use basedataset gsample 40 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth goodstrade goodstrade realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(49) mspeperiod(22(1)43) nested keep(prereftrainingOECDgt2016Fetzer40pc, replace) fig clear use basedataset gsample 60 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth goodstrade goodstrade realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(49) mspeperiod(22(1)43) nested keep(prereftrainingOECDgt2016Fetzer60pc, replace) fig clear use basedataset gsample 70 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth goodstrade goodstrade realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(49) mspeperiod(22(1)43) nested keep(prereftrainingOECDgt2016Fetzer70pc, replace) fig clear use basedataset gsample 80 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth goodstrade goodstrade realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(49) mspeperiod(22(1)43) nested keep(prereftrainingOECDgt2016Fetzer80pc, replace) fig clear use basedataset gsample 90 if UK==0, percent cluster(countryid) wor keep tsset ncountry dateid synth goodstrade goodstrade realgdp invratio schooling industry inflation openness realgdppercap, trunit(22) trperiod(49) mspeperiod(22(1)43) nested keep(prereftrainingOECDgt2016Fetzer90pc, replace) fig use prereftrainingOECDgt2016Fetzer50pc, clear rename _Y_synthetic fifty_pc merge 1:m _time using prereftrainingOECDgt2016Fetzer20pc rename _Y_synthetic twenty_pc drop _merge merge 1:m _time using prereftrainingOECDgt2016Fetzer30pc rename _Y_synthetic thirty_pc drop _merge merge 1:m _time using prereftrainingOECDgt2016Fetzer40pc rename _Y_synthetic forty_pc drop _merge merge 1:m _time using prereftrainingOECDgt2016Fetzer60pc rename _Y_synthetic sixty_pc drop _merge merge 1:m _time using prereftrainingOECDgt2016Fetzer70pc rename _Y_synthetic seventy_pc drop _merge merge 1:m _time using prereftrainingOECDgt2016Fetzer80pc rename _Y_synthetic eighty_pc drop _merge merge 1:m _time using prereftrainingOECDgt2016Fetzer90pc rename _Y_synthetic ninety_pc drop _merge merge 1:m _time using prereftrainingOECDgt2016Fetzer 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 prereftrainingOECDgt016Fetzeraverage, replace save prereftrainingOECDgt2016Fetzeraverage, replace