Dear all,
I have a broad data manipulation question that I haven't been able to solve. I want to create a dummy variable (called "surge") equal to one when variable "condition1" is equal to one, but only if eventually "condition2" also reaches one during the run. In the data sample below, for Botswana 2004-08, "surge" should be one, while for 2017-2019, "surge" should be zero because condition2 is zero between 2017-19. This is actually related to capital inflow surges literature in finance, where a surge episode is defined as capital inflow more than one standard deviation (condition 1) only if eventually it crosses the two standard deviation threshold (condition 2). I really appreciate your help. Thanks!
Best regards,
Abdan
I have a broad data manipulation question that I haven't been able to solve. I want to create a dummy variable (called "surge") equal to one when variable "condition1" is equal to one, but only if eventually "condition2" also reaches one during the run. In the data sample below, for Botswana 2004-08, "surge" should be one, while for 2017-2019, "surge" should be zero because condition2 is zero between 2017-19. This is actually related to capital inflow surges literature in finance, where a surge episode is defined as capital inflow more than one standard deviation (condition 1) only if eventually it crosses the two standard deviation threshold (condition 2). I really appreciate your help. Thanks!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str8 country int year byte(condition1 condition2) "Botswana" 2000 0 0 "Botswana" 2001 0 0 "Botswana" 2002 0 0 "Botswana" 2003 0 0 "Botswana" 2004 1 0 "Botswana" 2005 1 0 "Botswana" 2006 1 1 "Botswana" 2007 1 1 "Botswana" 2008 1 0 "Botswana" 2009 0 0 "Botswana" 2010 0 0 "Botswana" 2011 0 0 "Botswana" 2012 1 0 "Botswana" 2013 1 1 "Botswana" 2014 1 0 "Botswana" 2015 1 0 "Botswana" 2016 0 0 "Botswana" 2017 1 0 "Botswana" 2018 1 0 "Botswana" 2019 1 0 "Botswana" 2020 0 0 "Cambodia" 2000 0 0 "Cambodia" 2001 0 0 "Cambodia" 2002 0 0 "Cambodia" 2003 0 0 "Cambodia" 2004 1 1 "Cambodia" 2005 1 0 "Cambodia" 2006 1 1 "Cambodia" 2007 1 1 "Cambodia" 2008 1 0 "Cambodia" 2009 0 0 "Cambodia" 2010 0 0 "Cambodia" 2011 0 0 "Cambodia" 2012 1 0 "Cambodia" 2013 0 0 "Cambodia" 2014 1 1 "Cambodia" 2015 1 0 "Cambodia" 2016 0 0 "Cambodia" 2017 1 0 "Cambodia" 2018 1 0 "Cambodia" 2019 1 0 "Cambodia" 2020 0 0 end
Best regards,
Abdan

Comment