*! version 1.0 16 Jun 2023
help tofirsttreat

Title

tofirsttreat -- converting a treatment variable in a panel dataset from an indicator variable to a variable specifying the first treatment period

Syntax

tofirsttreat varname [, id(panelvar) time(timevar) generate(newvar)]

Description

The tofirsttreat command converts a treatment variable named varname in a panel dataset from an indicator variable to a variable specifying the first treatment period.
If a unit is not treated throughout the sample period, tofirsttreat designates the first treatment period as a missing value.

Options

id(panelvar) specifies panelvar as the panel variable of the dataset, which is used to identify the units (individuals) in the panel dataset.
If id(panelvar) is not specified, xtset must be used to declear a panel variable before implementing tofirsttreat.

time(timevar) specifies timevar as the time variable of the panel dataset. If time(timevar) is not specified, xtset must be used to declear a time variable before implementing tofirsttreat.

generate(newvar) specifies a new variable named newvar to store the transformed version of varname. If generate(newvar) is not specified, the transformed version of varname will replaces the original varname.

Example: the impact of bank deregulation on income inequality (Beck et al., 2010)

. use bbb.dta, clear

. xtset statefip wrkyr

. tofirsttreat _intra, generate(branch_reform_new)

. list statefip wrkyr _intra branch_reform_new in 1/124

Resources

didplacebo implements placebo tests for estimating difference-in-differences (DID) models

xtshuffle shuffles a variable in a panel dataset blockwise along the dimension of panel variable

xtrantreat randomizes a treatment variable in a panel dataset

Reference

Beck, T., Levine, R., and Levkov, A. 2010. Big bad banks? The winners and losers from bank deregulation in the United States. Journal of Finance 65(5): 1637-1667.

Chen, Q., Qi, J., and Yan, G. 2023. didplacebo: Implementing placebo tests for difference-in-differences estimations. Shandong University working paper.

Author

Qiang Chen, Shandong University, CN

www.econometrics-stata.com

qiang2chen2@126.com

Ji Qi, Shandong University, CN

miracle4556@163.com

Guanpeng Yan (correponding author), Shandong University of Finance and Economics, CN

guanpengyan@yeah.net