Skip to content

brycewang-stanford/Auto-Empirical-Research-Skills / skills/18-jusi-aalto-stata-accounting-research

stata-accounting-research

Unverified

STATA code pattern library for empirical archival accounting research. Provides tested syntax from 126 peer-reviewed JAR (Journal of Accounting Research) replication files (2017-2025). Use when the user asks procedural questions like "How do I implement [method]?" or "Show me code for [technique]" — including: entropy balancing, propensity score matching (PSM), difference-in-differences (DiD), regression discontinuity (RDD), instrumental variables (IV), event studies (CAR/BHAR), survival analysis, Fama-MacBeth regressions, bootstrap, quantile regression, reghdfe/xtreg/areg, clustering standard errors, fixed effects, esttab/outreg2 table formatting, winsorization, leads/lags. Users can specify their variables (e.g., treatment, outcomes, controls) and receive adapted syntax. NOTE: This skill provides code patterns from published papers, not research design advice.

FileKindSize
README-original.mdmarkdown2.9 KB
SKILL.mdskill md4.8 KB
references/JAR_55_bbcl.doother59.1 KB
references/JAR_55_chaplinksy-hanley-moon.doother46.3 KB
references/JAR_55_clm.doother95.1 KB
references/JAR_55_elw.doother58.0 KB
references/JAR_55_hlsw.doother104.1 KB
references/JAR_55_kks.doother365.5 KB
references/JAR_55_lzz.doother25.5 KB
references/JAR_55_madsen.doother307.5 KB
references/JAR_55_mr.doother41.5 KB
references/JAR_56_al.doother75.3 KB
references/JAR_56_bch.doother13.5 KB
references/JAR_56_blv.doother24.6 KB
references/JAR_56_csmw.doother27.6 KB
references/JAR_56_en.doother21.2 KB
references/JAR_56_granja.doother107.9 KB
references/JAR_56_htw.doother18.6 KB
references/JAR_56_kmt.doother5.6 KB
references/JAR_56_ksvw.doother8.0 KB
references/JAR_56_llz.doother3.1 KB
references/JAR_56_ls.doother147.5 KB
references/JAR_56_lv2018.doother123.7 KB
references/JAR_57_bht.doother24.4 KB
references/JAR_57_bl.doother22.6 KB
references/JAR_57_bw.doother263.2 KB
references/JAR_57_cct.doother347.1 KB
references/JAR_57_cgw.doother195.8 KB
references/JAR_57_hcp.doother38.0 KB
references/JAR_57_honigsberg.doother99.5 KB
references/JAR_57_lehmann.doother112.8 KB
references/JAR_57_lm.doother85.5 KB
references/JAR_58_bsz.doother36.9 KB
references/JAR_58_ckm.doother52.3 KB
references/JAR_58_eyring.doother58.1 KB
references/JAR_58_gj.doother187.5 KB
references/JAR_58_gsz.doother121.6 KB
references/JAR_58_htyz.doother30.9 KB
references/JAR_58_jansen.doother99.5 KB
references/JAR_58_joshi.doother43.0 KB
references/JAR_58_kvy.doother19.5 KB
references/JAR_58_msz.doother35.0 KB
references/JAR_58_rauter.doother433.2 KB
references/JAR_58_wy.doother64.5 KB
references/JAR_58_zz.doother125.5 KB
references/JAR_59_breuer.doother826.9 KB
references/JAR_59_ctv.doother383.7 KB
references/JAR_59_dess.doother78.4 KB
references/JAR_59_hmo.doother351.6 KB
references/JAR_60_abkp.doother129.9 KB
references/JAR_60_alv.doother35.4 KB
references/JAR_60_at.doother38.5 KB
references/JAR_60_barrios.doother119.6 KB
references/JAR_60_bbin.doother72.9 KB
references/JAR_60_bdem.doother11.6 KB
references/JAR_60_bl.doother43.5 KB
references/JAR_60_bmsw.doother7.7 KB
references/JAR_60_cc.doother20.1 KB
references/JAR_60_cpss.doother15.4 KB
references/JAR_60_cstv.doother175.3 KB
references/JAR_60_dg.doother19.9 KB
references/JAR_60_duguay.doother8.0 KB
references/JAR_60_fhl.doother71.3 KB
references/JAR_60_gls.doother37.0 KB
references/JAR_60_hmryz.doother28.6 KB
references/JAR_60_hst.doother18.3 KB
references/JAR_60_kt.doother10.4 KB
references/JAR_60_mliu.doother28.3 KB
references/JAR_60_nrwx.doother14.6 KB
references/JAR_60_ptwy.doother26.6 KB
references/JAR_60_skim.doother14.7 KB
references/JAR_61_bcdr.doother524.9 KB
references/JAR_61_bkr.doother51.6 KB
references/JAR_61_bls.doother79.2 KB
references/JAR_61_bo.doother29.7 KB
references/JAR_61_ccm.doother48.7 KB
references/JAR_61_cdss.doother3.9 KB
references/JAR_61_cfhll.doother47.1 KB
references/JAR_61_cfmp.doother12.7 KB
references/JAR_61_ckor.doother77.5 KB
references/JAR_61_cllw.doother11.2 KB
references/JAR_61_clm.doother11.0 KB
references/JAR_61_deller.doother368.9 KB
references/JAR_61_dlrtw.doother30.6 KB
references/JAR_61_dlz.doother13.6 KB
references/JAR_61_drs.doother15.8 KB
references/JAR_61_ds.doother197.5 KB
references/JAR_61_glt.doother1.9 KB
references/JAR_61_gyz.doother7.5 KB
references/JAR_61_ll.doother89.3 KB
references/JAR_61_lszz.doother15.9 KB
references/JAR_61_os.doother128.9 KB
references/JAR_61_zureich.doother22.2 KB
references/JAR_62_1_bdsy_banerjee_etal.doother6.6 KB
references/JAR_62_1_bhs_bouwens_etal.doother59.7 KB
references/JAR_62_1_gsz_gu_sun_zhou.doother46.6 KB
references/JAR_62_2_dgzz_defranco_etal.doother1.8 KB
references/JAR_62_2_gmp_grewal_etal.doother37.2 KB
references/JAR_62_2_xyz_xin_etal.doother25.3 KB
references/JAR_62_3_bht_bloomfield_etal.doother16.0 KB
references/JAR_62_3_ccz_cheynel_etal.doother23.3 KB
references/JAR_62_3_kim.doother2.6 KB
references/JAR_62_3_rr_raghunandan_ruchti.doother15.5 KB
references/JAR_62_4_bd_breuer_dehaan.doother15.3 KB
references/JAR_62_4_cc_cadman_carrizosa.doother20.1 KB
references/JAR_62_4_kmsv_kohler_etal.doother91.5 KB
references/JAR_62_4_mps_marra_etal.doother68.0 KB
references/JAR_62_4_raghunandan.doother50.0 KB
references/JAR_62_4_stv_sran_etal.doother41.1 KB
references/JAR_62_4_xu.doother49.4 KB
references/JAR_62_5_aov_abraham_etal.doother418.9 KB
references/JAR_62_5_gibbons.doother80.1 KB
references/JAR_62_5_jiang.doother114.3 KB
references/JAR_62_5_kstz_krueger_etal.doother26.7 KB
references/JAR_62_5_llz_li_lou_zhang.doother6.2 KB
references/JAR_62_5_lrst_lins_etal.doother66.2 KB
references/JAR_62_5_lswy_lin_etal.doother85.2 KB
references/JAR_62_5_lw_li_wang.doother16.6 KB
references/JAR_63_1_blmv_bastiaansen_etal.doother18.5 KB
references/JAR_63_1_cvw_chen_etal.doother61.2 KB
references/JAR_63_1_fgr_frankel_etal.doother30.3 KB
references/JAR_63_1_hrsx_huang_etal.doother35.5 KB
references/JAR_63_1_jia.doother12.0 KB
references/JAR_63_2_bcrw_bakke_etal.doother271.3 KB
references/JAR_63_2_dlr_desimone_etal.doother83.5 KB
references/JAR_63_2_mqtz_mao_etal.doother94.2 KB
references/JAR_63_2_npstv_nessa_etal.doother7.0 KB
references/JAR_63_3_breuer.doother51.4 KB
references/REFERENCES.mdmarkdown30.7 KB

references/JAR_58_joshi.do

View on GitHub

***Journal of Accounting Research****
***Does Private Country by Country Reporting Deter Tax Avoidance & Income Shifting? Evidence from BEPS Action Item 13***
*** Joshi (2020)***

*** Steps for downloading raw data, collating data and creating dependant and independant variables for the primary tax avoidance tests reported in tables 4-7***

*Step 1: Download data from Orbis using the data selection criteria's specified in sections 3.0 and 3.1 as well as in Table 1 of the paper
*Step 2: Download information on STR using OECD's tax database 
*Step 3: Download information on cash taxes paid from Compustat
*Step 4: Merge primary dataset from Orbis with the STR dataset using Country and Year as identifiers
*Step 5: Merge primary dataset from Orbis with the Compustat dataset using ISIN number and Year as identifiers
*Step 6: Compare the pre-tax income and total assets in the matched sample from step 5 and exclude any observations with discrepency
*Step 7: Create the dependant and independant variables used in the study
*Step 8: Conduct empirical analyses

******************************************************************************
*Step 1: Step 1: Download data from Orbis using the data selection criteria's specified in sections 3.0 and 3.1 as well as in Table 1 of the paper
The primary sample in the study consists of EU MNCs. I restrict the sample to EU MNCs because CbCr was effective in EU member states on the same date (January 1, 2016). 
In addition, the tax and legal environments in EU nations are comparable across jurisdictions, and there is better availability of affiliate-level data through 
databases compiled by Bureau van Dijk. I obtain annual financial statements and ownership data for the years 2010 to 2018 from the Orbis database (Bureau van Dijk). 
In the EU, a primary reporting obligation under CbCr arises when, in a multinational group, either the ultimate parent or a member of the group is resident in 
a member state. CbCr requirements for resident and nonresident EU firms when the parent entity is headquartered outside an EU member state depends on whether 
the parent jurisdiction has adopted the rules and on the exchange relationship between parent home country and EU member states. I therefore restrict my primary 
sample to EU headquartered firms and, in an additional analysis (section 8.3), include nonresident EU firms. I start with EU-headquartered firms that are identified 
as global ultimate owners in the Orbis database and that have at least one foreign subsidiary. I exclude financial institutions and firms in the extractive industries 
because they are subject to additional CbCr requirements.  After excluding firms with missing data required to calculate the regression variables, the final sample
 consists of 5,312 EU-headquartered multinationals (57,131 firm year-ends). 

 bysort BvDIDnumber:gen dup = cond(_N==1,0,_n)
drop if dup>1

reshape long varlist, i( BvDIDnumber) j(Year)
drop if misisng( BvDIDnumber)

tab Conscode
drop if Conscode=="U2"


*****************************************************************************
*Step 2:Download information on STR using OECD's tax database 
*https://www.oecd.org/tax/tax-policy/tax-database/



******************************************************************************
*Step 3: Download information on cash taxes paid from Compustat


******************************************************************************
*Step 4: Merge primary dataset from Orbis with the STR dataset using Country and Year as identifiers
merge m:m Year country using "C:\Users\STR Only.dta"
drop if misisng( BvDIDnumber)

***********************************************************************************************************************************************************
*Step 5: Merge primary dataset from Orbis with the Compustat dataset using ISIN number and Year as identifiers
merge m:m ISIN Year using "C:\Users\CETR.dta"
drop if misisng( BvDIDnumber)

***********************************************************************************************************************************************************

*Step 6: Compare the pre-tax income and total assets in the matched sample from step 5 and exclude any observations with discrepency
gen Match=0
replace Match=1 if PTI==PTI_CETR
gen Match1=0
replace Match1=1 if TA==TA_CETR

*****************************************************************************

*Step 7: Create the dependant and independant variables used in the study



gen ETR=TaxationmEUR/PLbeforetaxmEUR
gen MissingETR=0
replace MissingETR=1 if missing(ETR)
gen ETR_R=ETR
replace ETR_R=1 if ETR>1 & MissingETR==0
replace ETR_R=0 if ETR<0 & MissingETR==0

gen ETR_T=ETR
replace ETR_T=. if ETR>1 & MissingETR==0
replace ETR_T=. if ETR<0 & MissingETR==0

gen TaxDiff_R=ETR_R-STR
gen TaxDiff_T=ETR_T-STR

gen CETR=CashTaxPaid/PLbeforetaxmEUR
gen MissingCETR=0
replace MissingCETR=1 if missing(CETR)
gen CETR_R=CETR
replace CETR_R=1 if CETR>1 & MissingCETR==0
replace CETR_R=0 if CETR<0 & MissingCETR==0

gen CETR_T=ETR
replace CETR_T=. if CETR>1 & MissingCETR==0
replace CETR_T=. if CETR<0 & MissingCETR==0


gen ROA= NetIncome/ Totalassets if NetIncome>=0
replace ROA=. if ROA<0

gen Size=log( Totalassets) if Totalassets>0

gen Leverage=( TotalEquityLiab-ShareholdersfundsmEUR)/ Totalassets if Totalassets>0

gen Intang=log( Intangibles) if Intangibles>0

gen R&D= RD/ Totalassets if Totalassets>0

gen Innovation=( Numberofpatents+ Numberoftrademarks)/Totalassets if Totalassets>0



gen POST=1 if Year>2015
replace POST=0 if Year<2016

gen CETR=CashTaxes_CETR_w/PTI_CETR_w
gen MissingCETR=0
replace MissingCETR=1 if missing(CETR)

gen CETR_R=CETR
replace CETR_R=1 if CETR>1 & MissingCETR==0
replace CETR_R=0 if CETR<0 & MissingCETR==0

gen CETR_T=CETR
replace CETR_T=. if CETR>1 & MissingCETR==0
replace CETR_T=. if CETR<0 & MissingCETR==0


sort BvDIDnumber Year
by BvDIDnumber: egen PYRevenue=Revenue[_n-1]
gen CBCR=0
replace CBCR=1 if PYRevenue>=750 
replace CBCR=. if Year<2016
by BvDIDnumber: egen MaxCBCR=max(CBCR)
by BvDIDnumber: egen MinCBCR=min(CBCR)
gen Equals=1 if MaxCBCR==MinCBCR
rename CBCR CBCRPOST2015
rename MaxCBCR CBCR if Equals==1
gen CBCR_POST=CBCR*POST

gen EUHQ=0
replace EUHQ=1 if HQLocatedEU=1 
*HQLocatedEU is 1 if the headquarer of the company is located in one of the 21 EU member states
*****************************************************************************

*Step 8: Conduct empirical analyses (below I provide the codes for the base specifications used to estimate the results reported in tables 4-7 in the paper)

*Table 4 (t test)
ttest ETR_R if Year>2015, by(CBCR)
ttest ETR_R, by(BW1_250) 
ttest ETR_R, by(BW1_450) 
ttest ETR_R, by(BW1_550) 

ttest CETR_R if Year>2015, by(CBCR)
ttest CETR_R, by(BW1_250) 
ttest CETR_R, by(BW1_450) 
ttest CETR_R, by(BW1_550) 

ttest TaxDiff_R if Year>2015, by(CBCR)
ttest TaxDiff_R, by(BW1_250) 
ttest TaxDiff_R, by(BW1_450) 
ttest TaxDiff_R, by(BW1_550) 

ttest STR if Year>2015, by(CBCR)
ttest STR, by(BW1_250) 
ttest STR, by(BW1_450) 
ttest STR, by(BW1_550) 

*Table 5 (RDD Base Model)
eststo clear
eststo: rdrobust ETR_R PYRevenue if PYRevenue>0  & Year<2016 & EUHQ==1,  c(750)all
eststo: rdrobust ETR_R PYRevenue if PYRevenue>0  & Year>2015 & EUHQ==1,  c(750)all
eststo: rdrobust TaxDiff_R PYRevenue  if PYRevenue>0  & Year<2016 & EUHQ==1,  c(750)all
eststo: rdrobust TaxDiff_R PYRevenue  if PYRevenue>0  & Year>2015 & EUHQ==1,  c(750)all
eststo: rdrobust CETR_R PYRevenue  if PYRevenue>0  & Year<2016 & EUHQ==1,  c(750)all
eststo: rdrobust CETR_R PYRevenue  if PYRevenue>0  & Year>2015 & EUHQ==1,  c(750)all
esttab using ResultTable5.csv, ar2  p star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects

*Table 6 (DID Base Model) 
eststo: reghdfe ETR_R CBCR POST CBCR_POST if EUHQ==1, absorb (Firm Year) cluster(Firm)  
eststo: reghdfe TaxDiff_R CBCR POST CBCR_POST if EUHQ==1, absorb (Firm Year) cluster(Firm)  
eststo: reghdfe CETR_R CBCR POST CBCR_POST if EUHQ==1, absorb (Firm Year) cluster(Firm)  
esttab using ResultTable6.csv, ar2  se star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects

*** Steps for downloading raw data, collating data and creating dependant and independant variables for the primary income shifting tests reported in tables 8***

*Step 1: Start with the BVDId number of primary sample  used for the tax avoidance test. Following the data selection criteria's specified in sections 3.0 and 3.1 
*as well as in Table 1 in the paper, download financial information on the majority owned affiliates via Orbis
*Step 2: Merge CBCR indicator (as this indicator is calculated at the parent level) and other parent level variables with the affiliate dataset using the parent BVDID number
*Step 3: Create the dependant and independant variables used in the study
*Step 4: Conduct empirical analyses

******************************************************************************

*Step 1: Star with the BVDId number of primary sample  used for the tax avoidance test. Following the data selection criteria's specified in sections 3.0 and 3.1 

reshape long varlist , i( BvDIDnumber) j(Year)
drop if missing(BvDIDnumber)
******************************************************************************

*Step 2: Merge CBCR indicator (as this indicator is calculated at the parnet level) and other parent level variables with the affiliate dataset using the parent BVDID number

merge m:m GUOBvDIDnumber Year using "C:\Users\ParentData.dta"
drop if misisng( BvDIDnumber)

******************************************************************************
*Step 3: Create the dependant and independant variables used in the study


Calculation of C (Tax Incentive Variable)
*Though the formula to calculate C is not propriteary, the code developed is propriertary. As such instead of providing the code, I am providing a detail desciption of
*how C is calculated in section 7.0 of the paper. C is the weighted-average statutory tax rate faced by an affilaite and is calculated using the STR of all affiliates
*in thc corporate group as well as scale of firms' operations in the country. C is calculated using affiliate revenue as the measure of scale and alternate C is calculated
*using total assets.C is increasing in the tax burden faced by a firm’s affiliate relative to all other affiliates in the same year.  
 
gen missingC=1 if C==.
egen meanmissingC = mean( missingC), by(GUOBvDIDnumber Year)
egen totalmissingC = sum( missingC), by(GUOBvDIDnumber Year)
egen totalaffiliate = count( BvDIDnumber ), by(GUOBvDIDnumber Year)
gen dummy_affiliate=1
egen totalaffilliate = sum( dummy_affiliate ), by(GUOBvDIDnumber Year)
gen perctmissing= totalmissingC/ totalaffilliate

gen LogPTI=log( PTI) if PTI>=0
replace LogPTI=. if missing(PTI)
gen LogFA=log(Tangiblefixedassets) if Tangiblefixedassets>=0
replace LogFA=. if missing(Tangiblefixedassets)
gen LogGDP=log(GDP) if GDP>=0
gen LogComp=log(EmployeesCost) if EmployeesCost>0
gen LogEmp=log(Employees) if Employees>0
egen Firm=group(BvDIDnumber)
egen Industry=group(NACERev2Corecode4digits)
egen Parent=group(GUOBvDIDnumber)

gen POST=1 if Year>2015
replace POST=0 if Year<2016

*CBCR is determined at the parent level

gen POST_CBCR=POST*CBCR
gen C_POST=C*POST
gen C_POST_CBCR=C*POST*CBCR

******************************************************************************
*Step 4: Conduct empirical analyses

*Base Model used to estimate the results reported in table 8
eststo clear
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  , absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if perctmissingC<0.3 ,  absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if  perctmissingC<.2 ,  absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if  perctmissingC<.1 , absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if  perctmissingC==0 ,  absorb(Parent Year) cluster (Parent)
esttab using ResultTable8-1.csv,  ar2 se star(* 0.1 ** 0.05 *** 0.01)

*Base Model modified by including control variables and different fixed effects

******************************************************************************

*Codes for constructing variables used in the additional analyses 

*Table 7 (Panel A)
gen Year2013=0
replace Year2013=1 if Year==2013
gen CBCR_Year2013=CBCR*Year2013
gen Year2014=0
replace Year2014=1 if Year==2014
gen CBCR_Year2014=CBCR*Year2014
gen Year2015=0
replace Year2015=1 if Year==2015
gen CBCR_Year2015=CBCR*Year2015
gen Year2016=0
replace Year2016=1 if Year==2016
gen CBCR_Year2016=CBCR*Year2016
gen Year2017=0
replace Year2017=1 if Year==2017
gen CBCR_Year2017=CBCR*Year2017
gen Year2018=0
replace Year2018=1 if Year==2018
gen CBCR_Year2018=CBCR*Year2018

eststo: reghdfe ETR_R CBCR Year2013 Year2014 Year2015 Year2016 Year2017 Year2018 CBCR_Year2013 CBCR_Year2014 CBCR_Year2015 CBCR_Year2016 CBCR_Year2017 CBCR_Year2018 if EUHQ==1, absorb (Firm Year) cluster(Firm)
eststo: reghdfe TaxDiff_R CBCR Year2013 Year2014 Year2015 Year2016 Year2017 Year2018 CBCR_Year2013 CBCR_Year2014 CBCR_Year2015 CBCR_Year2016 CBCR_Year2017 CBCR_Year2018 if EUHQ==1, absorb (Firm Year) cluster(Firm)  
eststo: reghdfe CETR_R CBCR Year2013 Year2014 Year2015 Year2016 Year2017 Year2018 CBCR_Year2013 CBCR_Year2014 CBCR_Year2015 CBCR_Year2016 CBCR_Year2017 CBCR_Year2018 if EUHQ==1, absorb (Firm Year) cluster(Firm)    
esttab using ResultTable7PanelA.csv, ar2  se star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects

*Table 7 (Panel B)
eststo clear 
eststo: reghdfe ETR_R POST if CBCR==1 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe ETR_R POST if CBCR==0 &  EUHQ==1, absorb (Firm) cluster(Firm) 
eststo: reghdfe TaxDiff_R POST if CBCR==1 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe TaxDiff_R POST if CBCR==0 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe CETR_R POST if CBCR==1 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe CETR_R POST if CBCR==0 &  EUHQ==1, absorb (Firm) cluster(Firm)
esttab using ResultTable7PanelB.csv, ar2  se star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects


******************************************************************************

***Journal of Accounting Research****
***Does Private Country by Country Reporting Deter Tax Avoidance & Income Shifting? Evidence from BEPS Action Item 13***
*** Joshi (2020)***

*** Steps for downloading raw data, collating data and creating dependant and independant variables for the primary tax avoidance tests reported in tables 4-7***

*Step 1: Download data from Orbis using the data selection criteria's specified in sections 3.0 and 3.1 as well as in Table 1 of the paper
*Step 2: Download information on STR using OECD's tax database 
*Step 3: Download information on cash taxes paid from Compustat
*Step 4: Merge primary dataset from Orbis with the STR dataset using Country and Year as identifiers
*Step 5: Merge primary dataset from Orbis with the Compustat dataset using ISIN number and Year as identifiers
*Step 6: Compare the pre-tax income and total assets in the matched sample from step 5 and exclude any observations with discrepency
*Step 7: Create the dependant and independant variables used in the study
*Step 8: Conduct empirical analyses

******************************************************************************
*Step 1: Step 1: Download data from Orbis using the data selection criteria's specified in sections 3.0 and 3.1 as well as in Table 1 of the paper
The primary sample in the study consists of EU MNCs. I restrict the sample to EU MNCs because CbCr was effective in EU member states on the same date (January 1, 2016). 
In addition, the tax and legal environments in EU nations are comparable across jurisdictions, and there is better availability of affiliate-level data through 
databases compiled by Bureau van Dijk. I obtain annual financial statements and ownership data for the years 2010 to 2018 from the Orbis database (Bureau van Dijk). 
In the EU, a primary reporting obligation under CbCr arises when, in a multinational group, either the ultimate parent or a member of the group is resident in 
a member state. CbCr requirements for resident and nonresident EU firms when the parent entity is headquartered outside an EU member state depends on whether 
the parent jurisdiction has adopted the rules and on the exchange relationship between parent home country and EU member states. I therefore restrict my primary 
sample to EU headquartered firms and, in an additional analysis (section 8.3), include nonresident EU firms. I start with EU-headquartered firms that are identified 
as global ultimate owners in the Orbis database and that have at least one foreign subsidiary. I exclude financial institutions and firms in the extractive industries 
because they are subject to additional CbCr requirements.  After excluding firms with missing data required to calculate the regression variables, the final sample
 consists of 5,312 EU-headquartered multinationals (57,131 firm year-ends). 

 bysort BvDIDnumber:gen dup = cond(_N==1,0,_n)
drop if dup>1

reshape long varlist, i( BvDIDnumber) j(Year)
drop if misisng( BvDIDnumber)

tab Conscode
drop if Conscode=="U2"


*****************************************************************************
*Step 2:Download information on STR using OECD's tax database 
*https://www.oecd.org/tax/tax-policy/tax-database/



******************************************************************************
*Step 3: Download information on cash taxes paid from Compustat


******************************************************************************
*Step 4: Merge primary dataset from Orbis with the STR dataset using Country and Year as identifiers
merge m:m Year country using "C:\Users\STR Only.dta"
drop if misisng( BvDIDnumber)

***********************************************************************************************************************************************************
*Step 5: Merge primary dataset from Orbis with the Compustat dataset using ISIN number and Year as identifiers
merge m:m ISIN Year using "C:\Users\CETR.dta"
drop if misisng( BvDIDnumber)

***********************************************************************************************************************************************************

*Step 6: Compare the pre-tax income and total assets in the matched sample from step 5 and exclude any observations with discrepency
gen Match=0
replace Match=1 if PTI==PTI_CETR
gen Match1=0
replace Match1=1 if TA==TA_CETR

*****************************************************************************

*Step 7: Create the dependant and independant variables used in the study



gen ETR=TaxationmEUR/PLbeforetaxmEUR
gen MissingETR=0
replace MissingETR=1 if missing(ETR)
gen ETR_R=ETR
replace ETR_R=1 if ETR>1 & MissingETR==0
replace ETR_R=0 if ETR<0 & MissingETR==0

gen ETR_T=ETR
replace ETR_T=. if ETR>1 & MissingETR==0
replace ETR_T=. if ETR<0 & MissingETR==0

gen TaxDiff_R=ETR_R-STR
gen TaxDiff_T=ETR_T-STR

gen CETR=CashTaxPaid/PLbeforetaxmEUR
gen MissingCETR=0
replace MissingCETR=1 if missing(CETR)
gen CETR_R=CETR
replace CETR_R=1 if CETR>1 & MissingCETR==0
replace CETR_R=0 if CETR<0 & MissingCETR==0

gen CETR_T=ETR
replace CETR_T=. if CETR>1 & MissingCETR==0
replace CETR_T=. if CETR<0 & MissingCETR==0


gen ROA= NetIncome/ Totalassets if NetIncome>=0
replace ROA=. if ROA<0

gen Size=log( Totalassets) if Totalassets>0

gen Leverage=( TotalEquityLiab-ShareholdersfundsmEUR)/ Totalassets if Totalassets>0

gen Intang=log( Intangibles) if Intangibles>0

gen R&D= RD/ Totalassets if Totalassets>0

gen Innovation=( Numberofpatents+ Numberoftrademarks)/Totalassets if Totalassets>0



gen POST=1 if Year>2015
replace POST=0 if Year<2016

gen CETR=CashTaxes_CETR_w/PTI_CETR_w
gen MissingCETR=0
replace MissingCETR=1 if missing(CETR)

gen CETR_R=CETR
replace CETR_R=1 if CETR>1 & MissingCETR==0
replace CETR_R=0 if CETR<0 & MissingCETR==0

gen CETR_T=CETR
replace CETR_T=. if CETR>1 & MissingCETR==0
replace CETR_T=. if CETR<0 & MissingCETR==0


sort BvDIDnumber Year
by BvDIDnumber: egen PYRevenue=Revenue[_n-1]
gen CBCR=0
replace CBCR=1 if PYRevenue>=750 
replace CBCR=. if Year<2016
by BvDIDnumber: egen MaxCBCR=max(CBCR)
by BvDIDnumber: egen MinCBCR=min(CBCR)
gen Equals=1 if MaxCBCR==MinCBCR
rename CBCR CBCRPOST2015
rename MaxCBCR CBCR if Equals==1
gen CBCR_POST=CBCR*POST

gen EUHQ=0
replace EUHQ=1 if HQLocatedEU=1 
*HQLocatedEU is 1 if the headquarer of the company is located in one of the 21 EU member states
*****************************************************************************

*Step 8: Conduct empirical analyses (below I provide the codes for the base specifications used to estimate the results reported in tables 4-7 in the paper)

*Table 4 (t test)
ttest ETR_R if Year>2015, by(CBCR)
ttest ETR_R, by(BW1_250) 
ttest ETR_R, by(BW1_450) 
ttest ETR_R, by(BW1_550) 

ttest CETR_R if Year>2015, by(CBCR)
ttest CETR_R, by(BW1_250) 
ttest CETR_R, by(BW1_450) 
ttest CETR_R, by(BW1_550) 

ttest TaxDiff_R if Year>2015, by(CBCR)
ttest TaxDiff_R, by(BW1_250) 
ttest TaxDiff_R, by(BW1_450) 
ttest TaxDiff_R, by(BW1_550) 

ttest STR if Year>2015, by(CBCR)
ttest STR, by(BW1_250) 
ttest STR, by(BW1_450) 
ttest STR, by(BW1_550) 

*Table 5 (RDD Base Model)
eststo clear
eststo: rdrobust ETR_R PYRevenue if PYRevenue>0  & Year<2016 & EUHQ==1,  c(750)all
eststo: rdrobust ETR_R PYRevenue if PYRevenue>0  & Year>2015 & EUHQ==1,  c(750)all
eststo: rdrobust TaxDiff_R PYRevenue  if PYRevenue>0  & Year<2016 & EUHQ==1,  c(750)all
eststo: rdrobust TaxDiff_R PYRevenue  if PYRevenue>0  & Year>2015 & EUHQ==1,  c(750)all
eststo: rdrobust CETR_R PYRevenue  if PYRevenue>0  & Year<2016 & EUHQ==1,  c(750)all
eststo: rdrobust CETR_R PYRevenue  if PYRevenue>0  & Year>2015 & EUHQ==1,  c(750)all
esttab using ResultTable5.csv, ar2  p star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects

*Table 6 (DID Base Model) 
eststo: reghdfe ETR_R CBCR POST CBCR_POST if EUHQ==1, absorb (Firm Year) cluster(Firm)  
eststo: reghdfe TaxDiff_R CBCR POST CBCR_POST if EUHQ==1, absorb (Firm Year) cluster(Firm)  
eststo: reghdfe CETR_R CBCR POST CBCR_POST if EUHQ==1, absorb (Firm Year) cluster(Firm)  
esttab using ResultTable6.csv, ar2  se star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects

*** Steps for downloading raw data, collating data and creating dependant and independant variables for the primary income shifting tests reported in tables 8***

*Step 1: Start with the BVDId number of primary sample  used for the tax avoidance test. Following the data selection criteria's specified in sections 3.0 and 3.1 
*as well as in Table 1 in the paper, download financial information on the majority owned affiliates via Orbis
*Step 2: Merge CBCR indicator (as this indicator is calculated at the parent level) and other parent level variables with the affiliate dataset using the parent BVDID number
*Step 3: Create the dependant and independant variables used in the study
*Step 4: Conduct empirical analyses

******************************************************************************

*Step 1: Star with the BVDId number of primary sample  used for the tax avoidance test. Following the data selection criteria's specified in sections 3.0 and 3.1 

reshape long varlist , i( BvDIDnumber) j(Year)
drop if missing(BvDIDnumber)
******************************************************************************

*Step 2: Merge CBCR indicator (as this indicator is calculated at the parnet level) and other parent level variables with the affiliate dataset using the parent BVDID number

merge m:m GUOBvDIDnumber Year using "C:\Users\ParentData.dta"
drop if misisng( BvDIDnumber)

******************************************************************************
*Step 3: Create the dependant and independant variables used in the study


Calculation of C (Tax Incentive Variable)
*Though the formula to calculate C is not propriteary, the code developed is propriertary. As such instead of providing the code, I am providing a detail desciption of
*how C is calculated in section 7.0 of the paper. C is the weighted-average statutory tax rate faced by an affilaite and is calculated using the STR of all affiliates
*in thc corporate group as well as scale of firms' operations in the country. C is calculated using affiliate revenue as the measure of scale and alternate C is calculated
*using total assets.C is increasing in the tax burden faced by a firm’s affiliate relative to all other affiliates in the same year.  
 
gen missingC=1 if C==.
egen meanmissingC = mean( missingC), by(GUOBvDIDnumber Year)
egen totalmissingC = sum( missingC), by(GUOBvDIDnumber Year)
egen totalaffiliate = count( BvDIDnumber ), by(GUOBvDIDnumber Year)
gen dummy_affiliate=1
egen totalaffilliate = sum( dummy_affiliate ), by(GUOBvDIDnumber Year)
gen perctmissing= totalmissingC/ totalaffilliate

gen LogPTI=log( PTI) if PTI>=0
replace LogPTI=. if missing(PTI)
gen LogFA=log(Tangiblefixedassets) if Tangiblefixedassets>=0
replace LogFA=. if missing(Tangiblefixedassets)
gen LogGDP=log(GDP) if GDP>=0
gen LogComp=log(EmployeesCost) if EmployeesCost>0
gen LogEmp=log(Employees) if Employees>0
egen Firm=group(BvDIDnumber)
egen Industry=group(NACERev2Corecode4digits)
egen Parent=group(GUOBvDIDnumber)

gen POST=1 if Year>2015
replace POST=0 if Year<2016

*CBCR is determined at the parent level

gen POST_CBCR=POST*CBCR
gen C_POST=C*POST
gen C_POST_CBCR=C*POST*CBCR

******************************************************************************
*Step 4: Conduct empirical analyses

*Base Model used to estimate the results reported in table 8
eststo clear
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  , absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if perctmissingC<0.3 ,  absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if  perctmissingC<.2 ,  absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if  perctmissingC<.1 , absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if  perctmissingC==0 ,  absorb(Parent Year) cluster (Parent)
esttab using ResultTable8-1.csv,  ar2 se star(* 0.1 ** 0.05 *** 0.01)

*Base Model modified by including control variables and different fixed effects

******************************************************************************

*Codes for constructing variables used in the additional analyses 

*Table 7 (Panel A)
gen Year2013=0
replace Year2013=1 if Year==2013
gen CBCR_Year2013=CBCR*Year2013
gen Year2014=0
replace Year2014=1 if Year==2014
gen CBCR_Year2014=CBCR*Year2014
gen Year2015=0
replace Year2015=1 if Year==2015
gen CBCR_Year2015=CBCR*Year2015
gen Year2016=0
replace Year2016=1 if Year==2016
gen CBCR_Year2016=CBCR*Year2016
gen Year2017=0
replace Year2017=1 if Year==2017
gen CBCR_Year2017=CBCR*Year2017
gen Year2018=0
replace Year2018=1 if Year==2018
gen CBCR_Year2018=CBCR*Year2018

eststo: reghdfe ETR_R CBCR Year2013 Year2014 Year2015 Year2016 Year2017 Year2018 CBCR_Year2013 CBCR_Year2014 CBCR_Year2015 CBCR_Year2016 CBCR_Year2017 CBCR_Year2018 if EUHQ==1, absorb (Firm Year) cluster(Firm)
eststo: reghdfe TaxDiff_R CBCR Year2013 Year2014 Year2015 Year2016 Year2017 Year2018 CBCR_Year2013 CBCR_Year2014 CBCR_Year2015 CBCR_Year2016 CBCR_Year2017 CBCR_Year2018 if EUHQ==1, absorb (Firm Year) cluster(Firm)  
eststo: reghdfe CETR_R CBCR Year2013 Year2014 Year2015 Year2016 Year2017 Year2018 CBCR_Year2013 CBCR_Year2014 CBCR_Year2015 CBCR_Year2016 CBCR_Year2017 CBCR_Year2018 if EUHQ==1, absorb (Firm Year) cluster(Firm)    
esttab using ResultTable7PanelA.csv, ar2  se star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects

*Table 7 (Panel B)
eststo clear 
eststo: reghdfe ETR_R POST if CBCR==1 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe ETR_R POST if CBCR==0 &  EUHQ==1, absorb (Firm) cluster(Firm) 
eststo: reghdfe TaxDiff_R POST if CBCR==1 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe TaxDiff_R POST if CBCR==0 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe CETR_R POST if CBCR==1 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe CETR_R POST if CBCR==0 &  EUHQ==1, absorb (Firm) cluster(Firm)
esttab using ResultTable7PanelB.csv, ar2  se star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects


******************************************************************************

***Journal of Accounting Research****
***Does Private Country by Country Reporting Deter Tax Avoidance & Income Shifting? Evidence from BEPS Action Item 13***
*** Joshi (2020)***

*** Steps for downloading raw data, collating data and creating dependant and independant variables for the primary tax avoidance tests reported in tables 4-7***

*Step 1: Download data from Orbis using the data selection criteria's specified in sections 3.0 and 3.1 as well as in Table 1 of the paper
*Step 2: Download information on STR using OECD's tax database 
*Step 3: Download information on cash taxes paid from Compustat
*Step 4: Merge primary dataset from Orbis with the STR dataset using Country and Year as identifiers
*Step 5: Merge primary dataset from Orbis with the Compustat dataset using ISIN number and Year as identifiers
*Step 6: Compare the pre-tax income and total assets in the matched sample from step 5 and exclude any observations with discrepency
*Step 7: Create the dependant and independant variables used in the study
*Step 8: Conduct empirical analyses

******************************************************************************
*Step 1: Step 1: Download data from Orbis using the data selection criteria's specified in sections 3.0 and 3.1 as well as in Table 1 of the paper
The primary sample in the study consists of EU MNCs. I restrict the sample to EU MNCs because CbCr was effective in EU member states on the same date (January 1, 2016). 
In addition, the tax and legal environments in EU nations are comparable across jurisdictions, and there is better availability of affiliate-level data through 
databases compiled by Bureau van Dijk. I obtain annual financial statements and ownership data for the years 2010 to 2018 from the Orbis database (Bureau van Dijk). 
In the EU, a primary reporting obligation under CbCr arises when, in a multinational group, either the ultimate parent or a member of the group is resident in 
a member state. CbCr requirements for resident and nonresident EU firms when the parent entity is headquartered outside an EU member state depends on whether 
the parent jurisdiction has adopted the rules and on the exchange relationship between parent home country and EU member states. I therefore restrict my primary 
sample to EU headquartered firms and, in an additional analysis (section 8.3), include nonresident EU firms. I start with EU-headquartered firms that are identified 
as global ultimate owners in the Orbis database and that have at least one foreign subsidiary. I exclude financial institutions and firms in the extractive industries 
because they are subject to additional CbCr requirements.  After excluding firms with missing data required to calculate the regression variables, the final sample
 consists of 5,312 EU-headquartered multinationals (57,131 firm year-ends). 

 bysort BvDIDnumber:gen dup = cond(_N==1,0,_n)
drop if dup>1

reshape long varlist, i( BvDIDnumber) j(Year)
drop if misisng( BvDIDnumber)

tab Conscode
drop if Conscode=="U2"


*****************************************************************************
*Step 2:Download information on STR using OECD's tax database 
*https://www.oecd.org/tax/tax-policy/tax-database/



******************************************************************************
*Step 3: Download information on cash taxes paid from Compustat


******************************************************************************
*Step 4: Merge primary dataset from Orbis with the STR dataset using Country and Year as identifiers
merge m:m Year country using "C:\Users\STR Only.dta"
drop if misisng( BvDIDnumber)

***********************************************************************************************************************************************************
*Step 5: Merge primary dataset from Orbis with the Compustat dataset using ISIN number and Year as identifiers
merge m:m ISIN Year using "C:\Users\CETR.dta"
drop if misisng( BvDIDnumber)

***********************************************************************************************************************************************************

*Step 6: Compare the pre-tax income and total assets in the matched sample from step 5 and exclude any observations with discrepency
gen Match=0
replace Match=1 if PTI==PTI_CETR
gen Match1=0
replace Match1=1 if TA==TA_CETR

*****************************************************************************

*Step 7: Create the dependant and independant variables used in the study



gen ETR=TaxationmEUR/PLbeforetaxmEUR
gen MissingETR=0
replace MissingETR=1 if missing(ETR)
gen ETR_R=ETR
replace ETR_R=1 if ETR>1 & MissingETR==0
replace ETR_R=0 if ETR<0 & MissingETR==0

gen ETR_T=ETR
replace ETR_T=. if ETR>1 & MissingETR==0
replace ETR_T=. if ETR<0 & MissingETR==0

gen TaxDiff_R=ETR_R-STR
gen TaxDiff_T=ETR_T-STR

gen CETR=CashTaxPaid/PLbeforetaxmEUR
gen MissingCETR=0
replace MissingCETR=1 if missing(CETR)
gen CETR_R=CETR
replace CETR_R=1 if CETR>1 & MissingCETR==0
replace CETR_R=0 if CETR<0 & MissingCETR==0

gen CETR_T=ETR
replace CETR_T=. if CETR>1 & MissingCETR==0
replace CETR_T=. if CETR<0 & MissingCETR==0


gen ROA= NetIncome/ Totalassets if NetIncome>=0
replace ROA=. if ROA<0

gen Size=log( Totalassets) if Totalassets>0

gen Leverage=( TotalEquityLiab-ShareholdersfundsmEUR)/ Totalassets if Totalassets>0

gen Intang=log( Intangibles) if Intangibles>0

gen R&D= RD/ Totalassets if Totalassets>0

gen Innovation=( Numberofpatents+ Numberoftrademarks)/Totalassets if Totalassets>0



gen POST=1 if Year>2015
replace POST=0 if Year<2016

gen CETR=CashTaxes_CETR_w/PTI_CETR_w
gen MissingCETR=0
replace MissingCETR=1 if missing(CETR)

gen CETR_R=CETR
replace CETR_R=1 if CETR>1 & MissingCETR==0
replace CETR_R=0 if CETR<0 & MissingCETR==0

gen CETR_T=CETR
replace CETR_T=. if CETR>1 & MissingCETR==0
replace CETR_T=. if CETR<0 & MissingCETR==0


sort BvDIDnumber Year
by BvDIDnumber: egen PYRevenue=Revenue[_n-1]
gen CBCR=0
replace CBCR=1 if PYRevenue>=750 
replace CBCR=. if Year<2016
by BvDIDnumber: egen MaxCBCR=max(CBCR)
by BvDIDnumber: egen MinCBCR=min(CBCR)
gen Equals=1 if MaxCBCR==MinCBCR
rename CBCR CBCRPOST2015
rename MaxCBCR CBCR if Equals==1
gen CBCR_POST=CBCR*POST

gen EUHQ=0
replace EUHQ=1 if HQLocatedEU=1 
*HQLocatedEU is 1 if the headquarer of the company is located in one of the 21 EU member states
*****************************************************************************

*Step 8: Conduct empirical analyses (below I provide the codes for the base specifications used to estimate the results reported in tables 4-7 in the paper)

*Table 4 (t test)
ttest ETR_R if Year>2015, by(CBCR)
ttest ETR_R, by(BW1_250) 
ttest ETR_R, by(BW1_450) 
ttest ETR_R, by(BW1_550) 

ttest CETR_R if Year>2015, by(CBCR)
ttest CETR_R, by(BW1_250) 
ttest CETR_R, by(BW1_450) 
ttest CETR_R, by(BW1_550) 

ttest TaxDiff_R if Year>2015, by(CBCR)
ttest TaxDiff_R, by(BW1_250) 
ttest TaxDiff_R, by(BW1_450) 
ttest TaxDiff_R, by(BW1_550) 

ttest STR if Year>2015, by(CBCR)
ttest STR, by(BW1_250) 
ttest STR, by(BW1_450) 
ttest STR, by(BW1_550) 

*Table 5 (RDD Base Model)
eststo clear
eststo: rdrobust ETR_R PYRevenue if PYRevenue>0  & Year<2016 & EUHQ==1,  c(750)all
eststo: rdrobust ETR_R PYRevenue if PYRevenue>0  & Year>2015 & EUHQ==1,  c(750)all
eststo: rdrobust TaxDiff_R PYRevenue  if PYRevenue>0  & Year<2016 & EUHQ==1,  c(750)all
eststo: rdrobust TaxDiff_R PYRevenue  if PYRevenue>0  & Year>2015 & EUHQ==1,  c(750)all
eststo: rdrobust CETR_R PYRevenue  if PYRevenue>0  & Year<2016 & EUHQ==1,  c(750)all
eststo: rdrobust CETR_R PYRevenue  if PYRevenue>0  & Year>2015 & EUHQ==1,  c(750)all
esttab using ResultTable5.csv, ar2  p star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects

*Table 6 (DID Base Model) 
eststo: reghdfe ETR_R CBCR POST CBCR_POST if EUHQ==1, absorb (Firm Year) cluster(Firm)  
eststo: reghdfe TaxDiff_R CBCR POST CBCR_POST if EUHQ==1, absorb (Firm Year) cluster(Firm)  
eststo: reghdfe CETR_R CBCR POST CBCR_POST if EUHQ==1, absorb (Firm Year) cluster(Firm)  
esttab using ResultTable6.csv, ar2  se star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects

*** Steps for downloading raw data, collating data and creating dependant and independant variables for the primary income shifting tests reported in tables 8***

*Step 1: Start with the BVDId number of primary sample  used for the tax avoidance test. Following the data selection criteria's specified in sections 3.0 and 3.1 
*as well as in Table 1 in the paper, download financial information on the majority owned affiliates via Orbis
*Step 2: Merge CBCR indicator (as this indicator is calculated at the parent level) and other parent level variables with the affiliate dataset using the parent BVDID number
*Step 3: Create the dependant and independant variables used in the study
*Step 4: Conduct empirical analyses

******************************************************************************

*Step 1: Star with the BVDId number of primary sample  used for the tax avoidance test. Following the data selection criteria's specified in sections 3.0 and 3.1 

reshape long varlist , i( BvDIDnumber) j(Year)
drop if missing(BvDIDnumber)
******************************************************************************

*Step 2: Merge CBCR indicator (as this indicator is calculated at the parnet level) and other parent level variables with the affiliate dataset using the parent BVDID number

merge m:m GUOBvDIDnumber Year using "C:\Users\ParentData.dta"
drop if misisng( BvDIDnumber)

******************************************************************************
*Step 3: Create the dependant and independant variables used in the study


Calculation of C (Tax Incentive Variable)
*Though the formula to calculate C is not propriteary, the code developed is propriertary. As such instead of providing the code, I am providing a detail desciption of
*how C is calculated in section 7.0 of the paper. C is the weighted-average statutory tax rate faced by an affilaite and is calculated using the STR of all affiliates
*in thc corporate group as well as scale of firms' operations in the country. C is calculated using affiliate revenue as the measure of scale and alternate C is calculated
*using total assets.C is increasing in the tax burden faced by a firm’s affiliate relative to all other affiliates in the same year.  
 
gen missingC=1 if C==.
egen meanmissingC = mean( missingC), by(GUOBvDIDnumber Year)
egen totalmissingC = sum( missingC), by(GUOBvDIDnumber Year)
egen totalaffiliate = count( BvDIDnumber ), by(GUOBvDIDnumber Year)
gen dummy_affiliate=1
egen totalaffilliate = sum( dummy_affiliate ), by(GUOBvDIDnumber Year)
gen perctmissing= totalmissingC/ totalaffilliate

gen LogPTI=log( PTI) if PTI>=0
replace LogPTI=. if missing(PTI)
gen LogFA=log(Tangiblefixedassets) if Tangiblefixedassets>=0
replace LogFA=. if missing(Tangiblefixedassets)
gen LogGDP=log(GDP) if GDP>=0
gen LogComp=log(EmployeesCost) if EmployeesCost>0
gen LogEmp=log(Employees) if Employees>0
egen Firm=group(BvDIDnumber)
egen Industry=group(NACERev2Corecode4digits)
egen Parent=group(GUOBvDIDnumber)

gen POST=1 if Year>2015
replace POST=0 if Year<2016

*CBCR is determined at the parent level

gen POST_CBCR=POST*CBCR
gen C_POST=C*POST
gen C_POST_CBCR=C*POST*CBCR

******************************************************************************
*Step 4: Conduct empirical analyses

*Base Model used to estimate the results reported in table 8
eststo clear
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  , absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if perctmissingC<0.3 ,  absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if  perctmissingC<.2 ,  absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if  perctmissingC<.1 , absorb(Parent Year) cluster (Parent)
eststo: reghdfe LogPTI C CBCR POST CBCR_POST  C_CBCR C_POST C_CBCR_POST LogFA LogComp LogGDP  if  perctmissingC==0 ,  absorb(Parent Year) cluster (Parent)
esttab using ResultTable8-1.csv,  ar2 se star(* 0.1 ** 0.05 *** 0.01)

*Base Model modified by including control variables and different fixed effects

******************************************************************************

*Codes for constructing variables used in the additional analyses 

*Table 7 (Panel A)
gen Year2013=0
replace Year2013=1 if Year==2013
gen CBCR_Year2013=CBCR*Year2013
gen Year2014=0
replace Year2014=1 if Year==2014
gen CBCR_Year2014=CBCR*Year2014
gen Year2015=0
replace Year2015=1 if Year==2015
gen CBCR_Year2015=CBCR*Year2015
gen Year2016=0
replace Year2016=1 if Year==2016
gen CBCR_Year2016=CBCR*Year2016
gen Year2017=0
replace Year2017=1 if Year==2017
gen CBCR_Year2017=CBCR*Year2017
gen Year2018=0
replace Year2018=1 if Year==2018
gen CBCR_Year2018=CBCR*Year2018

eststo: reghdfe ETR_R CBCR Year2013 Year2014 Year2015 Year2016 Year2017 Year2018 CBCR_Year2013 CBCR_Year2014 CBCR_Year2015 CBCR_Year2016 CBCR_Year2017 CBCR_Year2018 if EUHQ==1, absorb (Firm Year) cluster(Firm)
eststo: reghdfe TaxDiff_R CBCR Year2013 Year2014 Year2015 Year2016 Year2017 Year2018 CBCR_Year2013 CBCR_Year2014 CBCR_Year2015 CBCR_Year2016 CBCR_Year2017 CBCR_Year2018 if EUHQ==1, absorb (Firm Year) cluster(Firm)  
eststo: reghdfe CETR_R CBCR Year2013 Year2014 Year2015 Year2016 Year2017 Year2018 CBCR_Year2013 CBCR_Year2014 CBCR_Year2015 CBCR_Year2016 CBCR_Year2017 CBCR_Year2018 if EUHQ==1, absorb (Firm Year) cluster(Firm)    
esttab using ResultTable7PanelA.csv, ar2  se star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects

*Table 7 (Panel B)
eststo clear 
eststo: reghdfe ETR_R POST if CBCR==1 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe ETR_R POST if CBCR==0 &  EUHQ==1, absorb (Firm) cluster(Firm) 
eststo: reghdfe TaxDiff_R POST if CBCR==1 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe TaxDiff_R POST if CBCR==0 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe CETR_R POST if CBCR==1 &  EUHQ==1, absorb (Firm) cluster(Firm)  
eststo: reghdfe CETR_R POST if CBCR==0 &  EUHQ==1, absorb (Firm) cluster(Firm)
esttab using ResultTable7PanelB.csv, ar2  se star(* 0.1 ** 0.05 *** 0.01)
*Base Model modified by including control variables and different fixed effects


******************************************************************************

brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 323kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall