/*Deflation code for project Inside the Production Function - The Effect of Financial Contracts on Growing Firms' Technology Use. Evidence from a field experiment in Uganda. Written by Miri Stryjan on 01 Dec 2017 */

/*Explanation: The code deflates monetary values expressed in Ugandan Shillings (UGX) to their November 2014 value. The calculation is based on the CPI (Headline: (Base: 2009/10 =100)) taken from Bank of Uganda: https://www.bou.or.ug/bou/rates_statistics/statistics.html on December 1, 2017*/

/*Note: the variables listed in the varlist below are only examples of variables that can be deflated using this code*/ 

local varlist profit_last30d sales_last30d

foreach x in `varlist’{

	g `x'_d=`x'
	
	replace `x'_d=`x'*	1	if start_interview>td(1oct2014)&start_interview<td(1nov2014)					
replace `x'_d=`x'*	1.001534456	if start_interview>td(31oct2014)&start_interview<td(1dec2014)					
replace `x'_d=`x'*	1.003075787	if start_interview>td(30nov2014)&start_interview<td(1jan2015)					
replace `x'_d=`x'*	0.995800763	if start_interview>td(31dec2014)&start_interview<td(1feb2015)					
replace `x'_d=`x'*	0.99169091	if start_interview>td(31jan2015)&start_interview<td(1mar2015)					
replace `x'_d=`x'*	0.976080001	if start_interview>td(28feb2014)&start_interview<td(1apr2015)					
replace `x'_d=`x'*	0.964167813	if start_interview>td(31mar2015)&start_interview<td(1may2015)					
replace `x'_d=`x'*	0.963939889	if start_interview>td(30apr2015)&start_interview<td(1jun2015)					
replace `x'_d=`x'*	0.967872361	if start_interview>td(31may2015)&start_interview<td(1jul2015)					
replace `x'_d=`x'*	0.959531682	if start_interview>td(30jun2015)&start_interview<td(1aug2015)					
replace `x'_d=`x'*	0.951027954	if start_interview>td(31jul2015)&start_interview<td(1sep2015)					
replace `x'_d=`x'*	0.937370176	if start_interview>td(31aug2015)&start_interview<td(1oct2015)					
replace `x'_d=`x'*	0.928992302	if start_interview>td(30sep2015)&start_interview<td(1nov2015)					
replace `x'_d=`x'*	0.927226171	if start_interview>td(31oct2015)&start_interview<td(1dec2015)					
replace `x'_d=`x'*	0.92549064	if start_interview>td(30nov2015)&start_interview<td(1jan2016)					
replace `x'_d=`x'*	0.927384753	if start_interview>td(31dec2015)&start_interview<td(1feb2016)					
replace `x'_d=`x'*	0.926461589	if start_interview>td(31jan2016)&start_interview<td(1mar2016)					
replace `x'_d=`x'*	0.91805557	if start_interview>td(29feb2016)&start_interview<td(1apr2016)					
replace `x'_d=`x'*	0.91714523	if start_interview>td(31mar2016)&start_interview<td(1may2016)					
replace `x'_d=`x'*	0.915850575	if start_interview>td(30apr2016)&start_interview<td(1jun2016)					
replace `x'_d=`x'*	0.914215329	if start_interview>td(31may2016)&start_interview<td(1jul2016)					
replace `x'_d=`x'*	0.912394355	if start_interview>td(30jun2016)&start_interview<td(1aug2016)					
replace `x'_d=`x'*	0.906982912	if start_interview>td(31jul2016)&start_interview<td(1sep2016)					
replace `x'_d=`x'*	0.89898627	if start_interview>td(31aug2016)&start_interview<td(1oct2016)					
replace `x'_d=`x'*	0.891967309	if start_interview>td(30sep2016)&start_interview<td(1nov2016)					
replace `x'_d=`x'*	0.886318695	if start_interview>td(31oct2016)&start_interview<td(1dec2016)					
replace `x'_d=`x'*	0.875610427	if start_interview>td(30nov2016)&start_interview<td(1jan2017)					
replace `x'_d=`x'*	0.875663451	if start_interview>td(31dec2016)&start_interview<td(1feb2017)					
replace `x'_d=`x'*	0.868172284	if start_interview>td(31jan2017)&start_interview<td(1mar2017)					
replace `x'_d=`x'*	0.862549583	if start_interview>td(28feb2017)&start_interview<td(1apr2016)					
replace `x'_d=`x'*	0.858740817	if start_interview>td(31mar2017)&start_interview<td(1may2017)					
replace `x'_d=`x'*	0.853890744	if start_interview>td(30apr2017)&start_interview<td(1jun2017)					
replace `x'_d=`x'*	0.859203565	if start_interview>td(31may2017)&start_interview<td(1jul2017)					
replace `x'_d=`x'*	0.863354123	if start_interview>td(30jun2017)&start_interview<td(1aug2017)					
replace `x'_d=`x'*	0.861900678	if start_interview>td(31jul2017)&start_interview<td(1sep2017)					
replace `x'_d=`x'*	0.85377653	if start_interview>td(31aug2017)&start_interview<td(1oct2017)					
replace `x'_d=`x'*	0.851053642	if start_interview>td(30sep2017)&start_interview<td(1nov2017)					
replace `x'_d=`x'*	0.852373812	if start_interview>td(31oct2017)&start_interview<td(1dec2017)					

}