* do e:\DHS\programs\tests\diffs_between_surveys_do_22July2016.txt set logtype text log using e:\DHS\programs\tests\diffs_between_surveys_log_22July2016.txt, replace * Tom Pullum, tom.pullum@icfi.com, July 25, 2016 set more off cd e:\DHS\DHS_data\KR_files **************************************************************** program define setup1 * Construct the indicator, number the surveys, save the needed variables scalar ssurvey=ssurvey+1 local lsurvey=ssurvey gen survey=ssurvey * CONSTRUCT THE INDICATOR * values other than 0 and 1 should be interpreted as . replace g100=. if g100>1 replace g102=. if g102>1 gen y = . replace y=0 if g100<. replace y=1 if g102==1 keep v005 v021 v023 y survey save temp_`lsurvey'.dta, replace end **************************************************************** program define setup2 * Combine the surveys into one file use temp_1.dta, clear append using temp_2.dta egen cluster=group(v021 survey) egen stratum=group(v023 survey) save temp.dta, replace end **************************************************************** program define analyze * Test whether the "survey" variable statistically significant svyset cluster [pweight=v005], strata(stratum) singleunit(scaled) tab survey y tab survey y [iweight=v005/1000000], row * Test for significance of change or difference svy: logit y i.survey scalar p=e(p) scalar list p end **************************************************************** **************************************************************** **************************************************************** **************************************************************** **************************************************************** * EXECUTION BEGINS HERE * Example: difference between two surveys in FGM prevalence * Kenya 27.1% in 2008-09 vs 21.0% in 2014 * Uganda 0.6% in 2006 vs. 1.4% in 2011 scalar ssurvey=0 use e:\DHS\DHS_data\IR_files\KEIR52FL.dta, clear setup1 use e:\DHS\DHS_data\IR_files\KEIR70FL.dta, clear setup1 setup2 analyze clear scalar ssurvey=0 * In the Uganda surveys we must construct the strata and rename the outcome variables * Uganda 2006 use e:\DHS\DHS_data\IR_files\UGIR52FL.dta rename s643a g100 rename s643b g102 drop v023 egen v023=group(v024 v025) setup1 * Uganda 2011 use e:\DHS\DHS_data\IR_files\UGIR60FL.dta rename s631d g100 rename s631f g102 drop v023 egen v023=group(v024 v025) setup1 setup2 analyze * p is the significance of a test of H0: in the population, there was no difference * in the prevalence of the outcome across the surveys