JMSLab / xtevent

Stata package -xtevent-
MIT License
43 stars 12 forks source link

#191 Preserve oldvars for cleanup #196

Closed jorpppp closed 3 months ago

jorpppp commented 3 months ago

Closes #191

jorpppp commented 3 months ago

@Constantino-Carreto-Romero Can you please test this fix to make sure there aren't any unintended consequences before merging?

Constantino-Carreto-Romero commented 3 months ago

@jorpppp I tested the following examples and the outcomes were as expected. I also ran the test file without inconvenience (I found a small inconsistency not related to the implementation, but I changed it in https://github.com/JMSLab/xtevent/commit/b4322e1ccca52e96d2f7d8244ffab8337b1c55d9). Therefore, I think everything looks good.

* event-time dummies 
use example31, clear 
gen _k_eq_p0=runiform()
*expect the error "You have variables with prefix _k ..." but the program doesn't drop that variable
cap noi xtevent y eta _k_eq_p0, panelvar(i) timevar(t) pol(z) impute(stag) window(5) 

drop _k_eq_p0
gen _ttrend=runiform()
gen __k=runiform()
*it return the error "variable __k already defined", but it doesn't drop the created variable 
cap noi xtevent y eta, panelvar(i) timevar(t) pol(z) impute(stag) window(5) 

**** IV
use example31, clear 
gen _fd2z=runiform()
*No expected error because the program uses a temporary copy of z 
xtevent y eta, panelvar(i) timevar(t) pol(z) impute(stag, saveimp) window(5) proxy(x) proxyiv(2)

**** SA 
use example31, clear 
gen aa_interact_p1_c5=runiform()
* message error "You have variable names with the aa_interact prefix...", but the program doesn't drop the created variable
cap noi xtevent y eta, panelvar(i) timevar(t) pol(z) impute(stag) window(5) sunabraham savek(aa, saveint)
jorpppp commented 3 months ago

Thanks @Constantino-Carreto-Romero , merging now.