************************************************************************* ******** Project RCT on BdP/CRAS - DATABASE - March 16th, 2018 ********** ******************* BY LEANDRO SIMOES PONGELUPPE ************************ ************************************************************************* * data and cd clear all set more off cap log close cd "C:\Users\l.pongeluppe16\Desktop\STATA\RCT BdP" log using "2018_03_16_RCT.smcl", replace ************************************************************************* ******** Project RCT on BdP/CRAS - DATABASE - March 16th, 2018 ********** ******************* BY LEANDRO SIMOES PONGELUPPE ************************ ************************************************************************ local cras_period CDD_1 CDD_2 Pavuna_1 Pavuna_2 foreach unit of local cras_period { ** Include with name of cras_period use "DB_`unit'.dta", clear * Set more off . set more off * ENCODE AND LABEL VARIABLES * Socioeconomic ** Sex label define lsex 0 "masc" 1 "fem", replace encode sexo, gen(co_sex) label(lsex) noextend ** Race label define lrace 0 "black" 1 "brown" 2 "white", replace encode Raça, gen(co_race) label(lrace) *RENAME VARIABLES rename Nº id rename NomeReferência name rename NºNIS nis rename idade age rename rendainicial income_t0 rename rendainicialpercapita income_t0_percap rename Raça race rename sexo sex rename Nºmembros family_size rename ExperiênciaProfissional job_exp * Dummy Race quietly tabulate co_race, gen(d_race) * Summarize covariates summarize id name nis age income_t0 income_t0_percap family_size co_sex d_race1 d_race2 d_race3 job_exp * covariates local id name nis age income_t0 income_t0_percap family_size job_exp co_sex co_race foreach x of local cov { tabulate `x' } **************************************************************************************************** * Possible Stratas *Age - Cutoff Median Age (34 years-old) for the 280 individuals. gen strat_age = 0 replace strat_age = 1 if age > 34 *Income_t0 - Cutoff has any income or only Bolsa Familia gen strat_income_t0 = 0 replace strat_income_t0 = 1 if income_t0 > 0 *Income_t0_percapita - Cutoff has any income or only Bolsa Familia gen strat_income_t0_percap = 0 replace strat_income_t0_percap = 1 if strat_income_t0_percap > 0 *Sex gen strat_sex = co_sex *Family Size egen med_family_size = median(family_size) tab med_family_size gen strat_family_size = 0 replace strat_family_size = 1 if family_size > med_family_size *Race gen strat_race = co_race *Job Experience gen strat_job_exp = job_exp *tabulate stratas tab strat_age tab strat_income_t0 tab strat_income_t0_percap tab strat_sex tab strat_family_size tab strat_race tab strat_job_exp * Final STRATA * Generate Stratacta Bins considering the Stractas: Age, Income_t0_percap sort strat_age strat_income_t0 egen sbin = group (strat_age strat_income_t0) tab sbin *Randomization randtreat, generate(treatment) replace unequal (1/2 1/2) strata(sbin) setseed(20180316) misfits(wglobal) tab treatment * Treatment gen group = "Control" replace group = "Treated" if treatment == 1 label define lgroup 0 "Control" 1 "Treated" encode group, gen(co_group) label(lgroup) noextend tab group * Balance Tables local cov age income_t0 income_t0_percap family_size co_sex d_race1 d_race2 d_race3 job_exp set matsize 1000 local i = 0 * Set the last line of the matrix local last = 10 matrix define ttest_tab = J(`last', 3,.) foreach x of local cov { local i = `i' +1 ttest `x', by(group) matrix ttest_tab [`i',1] = r(mu_1) matrix ttest_tab [`i',2] = r(mu_2) matrix ttest_tab [`i',3] = r(p) matrix ttest_tab [`last', 1] = r(N_1) matrix ttest_tab [`last', 2] = r(N_2) } matrix rownames ttest_tab = age income_t0 income_t0_percap family_size co_sex white black brown job_exp Observations matrix colnames ttest_tab = Control Treated T-Test matrix list ttest_tab putexcel A1=matrix(ttest_tab, names) using 2018_03_16_RCT_ttest_tab_`unit', replace sort group save 2018_03_16_RCT_Result, replace export excel using "C:\Users\l.pongeluppe16\Desktop\STATA\RCT BdP\2018_03_16_RCT_Result_`unit'.xlsx", sheetreplace firstrow(variables) * Backup list (Wildcard) among control group - this individuals will be considered to fulfill the spot of people that drop out if and only if the drop out is in the first week. The drop outs will be monitored and accounted as attrition. * Following procedure recommended by World Bank at: Accessed on March 04th * set seed set seed 20180316 * Generating random numbers accordingly to the sbin strata preserve drop if group == "Treated" gen group_backup = . gen rand_num_backup = uniform() egen ordering_backup = rank(rand_num_backup), by(sbin) replace group_backup = 1 if ordering_backup <= 10 replace group_backup = 0 if ordering_backup > 10 gen rank_backup = group_backup*ordering_backup sort rank_backup tabulate group_backup drop if rank_backup == 0 save 2018_03_16_Backup_List_`unit', replace export excel using "C:\Users\l.pongeluppe16\Desktop\STATA\RCT BdP\2018_03_16_Backup_List_`unit'.xlsx", sheetreplace firstrow(variables) restore } *log closing log close print "2018_03_16_RCT.smcl", replace exit, clear