replace health_expenses=h403 if n4b==6 & h404==1 & h405==1 replace health_expenses=h403/12 if n4b==6 & h404==1 & h405==2 replace health_expenses=h403*47.01 if n4b==6 & h404==2 & h405==1 replace health_expenses=h403*47.01/12 if n4b==6 & h404==2 & h405==2 bro egen health_expenses_all=total(health_expenses), by(hhid) bro drop n4b h403 h404 h405 health_expenses bro duplicates drop bro duplicates report hhid save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh4b_new.dta", replace bro use "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\hh5.dta" save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh5_new.dta" bro egen all_income=total(h502), by(hhid) bro gen remittance_2=h502 if n5==15 bro bysort hhid (remittance_2): replace remittance_2=remittance_2[1] bro replace remittance_2=0 if remittance_2==. br gen income=all_income-remittance_2 br drop n5 h501 h502 all_income br duplicates drop duplicates report hhid save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh5_new.dta", replace use "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\hh6b.dta" save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh6b_new.dta" keep hhid h617_s h617_c h617_t gen remittance_1= h617_s if h617_c==1 & h617_t==1 replace remittance_1=h617_s/12 if h617_c==1 & h617_t==2 replace remittance_1=h617_s*47.01 if h617_c==2 & h617_t==1 replace remittance_1=h617_s*47.01/12 if h617_c==2 & h617_t==2 replace remittance_1=h617_s*1.51 if h617_c==3 & h617_t==1 replace remittance_1=h617_s*1.51/12 if h617_c==3 & h617_t==2 replace remittance_1=h617_s*60.44 if h617_c==4 & h617_t==1 replace remittance_1=h617_s*60.44/12 if h617_c==4 & h617_t==2 br bro drop h617_s h617_c h617_t duplicates report hhid save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh6b_new.dta", replace use "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh1a_new.dta" merge 1:1 hhid using "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh4b_new.dta" br save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh1a-hh4b_new.dta" rename _merge _merge_hh1a_hh4b merge 1:1 hhid using "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh5_new.dta" save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh1a-hh4b-hh5_new.dta" rename _merge _merge_hh1a_hh4b_hh5 merge 1:1 hhid using "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh6b_new.dta" save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh1a-hh4b-hh5-hh6b_new.dta"