My data is stored in a panel data format. I want to estimate the ARDL model that accommodates one structural break. The break dates are identified using the Bai-Perron test. Suppose I have data for 3 countries (identified by "ID" variable). The break dates are 2004 2001 2003. So, I wrote the following code:

Code:
forvalues i = 1/3 {
foreach j in 2004 2001 2003 {
use dataex, clear
keep if id==`i'
tab id if id==`i'
*egen trend=_n
gen DU=0
gen DTB=0

di "id        =`i'"
di "year      =`j'"

tsset year, yearly
// genarating break dummies
replace DU=1 if year>`j'
replace DTB= DU*trend if year>`j'
ardl x y, exo(DU DTB) maxcombs()
ardl x y, exo(DU DTB) ec maxcombs()
estat btest, n(25)
*outreg2 using "ARDL_results1", excel dec(2) br adjr2
} 
}
*

When I ran the above code it is estimating 9 ARDL models. But I want 3 models to be estimated, one country with one break. That is to, say, when ID=1, it should accommodate break date which is 2004. The next ARDL model for ID=2 should accommodate break date 2001.

When I run the above command, it is not running successfully. The dataex is the following:

Here is the data

Code:
clear all
input int id year x y
1 1993 1.3 16.32229
1 1994 1.19 16.37688
1 1995 0.87 16.43435
1 1996 0.97 16.49549
1 1997 1.04 16.48168
1 1998 1.04 16.59641
1 1999 1.01 16.64122
1 2000 1.05 16.7197
1 2001 1 16.76099
1 2002 0.98 16.78788
1 2003 0.95 16.87725
1 2004 0.84 16.95561
1 2005 0.83 17.00773
1 2006 0.82 17.11077
1 2007 0.92 17.23401
1 2008 0.96 17.25514
1 2009 0.98 17.32504
1 2010 1.03 17.39092
1 2011 1.11 17.45152
1 2012 1.01 17.45475
1 2013 1.04 17.52202
1 2014 0.7 17.61002
1 2015 0.6 17.71079
1 2016 0.67 17.81573
1 2017 0.58 17.92209
2 1993 1.57 15.89891
2 1994 1.53 16.00251
2 1995 1.08 15.85265
2 1996 0.95 16.06596
2 1997 0.95 16.02667
2 1998 0.95 16.09982
2 1999 1.42 16.13595
2 2000 1.16 16.28473
2 2001 0.85 16.23624
2 2002 0.81 16.34799
2 2003 0.76 16.29516
2 2004 0.64 16.41004
2 2005 0.91 16.39299
2 2006 0.83 16.54298
2 2007 0.86 16.59703
2 2008 0.71 16.73281
2 2009 0.71 16.78492
2 2010 0.61 16.92499
2 2011 0.61 17.0229
2 2012 0.54 17.06142
2 2013 0.55 17.11005
2 2014 0.85 17.14586
2 2015 0.84 17.20201
2 2016 0.98 17.29607
2 2017 1.16 17.4032
3 1993 1.42 13.74485
3 1994 1.26 13.79311
3 1995 1.2 13.86607
3 1996 1.19 14.00822
3 1997 1.09 14.0362
3 1998 1.1 14.23988
3 1999 1.09 14.26074
3 2000 1.08 14.22263
3 2001 1.08 14.26661
3 2002 1.01 14.33512
3 2003 0.99 14.40737
3 2004 0.89 14.50444
3 2005 0.87 14.57711
3 2006 0.82 14.67261
3 2007 0.76 14.72656
3 2008 0.87 14.82205
3 2009 0.94 14.91921
3 2010 0.98 15.07526
3 2011 0.87 15.25929
3 2012 1.06 15.09228
3 2013 1.21 14.96508
3 2014 1 15.20471
3 2015 0.96 15.34354
3 2016 0.95 15.46122
3 2017 1.07 15.58947
end

Any suggestions will be greatly appreciated.