use "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\hh1a.dta" save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh1a_new.dta" keep hhid pid age h102 h104 h108 bysort hhid: egen hhsize=count(pid) bysort hhid: egen males_over_15=count(pid) if age>15 & h102==1 bysort hhid ( males_over_15): replace males_over_15= males_over_15[1] replace males_over_15=0 if males_over_15==. bysort hhid: egen child_under_5=count(pid) if age<5 bysort hhid ( child_under_5 ): replace child_under_5 = child_under_5[1] replace child_under_5 =0 if child_under_5 ==. bysort hhid: gen female_hh_head=1 if h102==2 & h104==1 bysort hhid ( female_hh_head ): replace female_hh_head = female_hh_head[1] replace female_hh_head =0 if female_hh_head ==. bysort hhid: gen married_hh_head=1 if h108==1 & h104==1 bysort hhid ( married_hh_head ): replace married_hh_head = married_hh_head[1] replace married_hh_head =0 if married_hh_head ==. drop pid age h102 h104 h108 duplicates drop duplicates report hhid save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh1a_new.dta", replace use "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\hh4b.dta" save "C:\Users\Asus\Documents\AUCA\Teaching\2022-2023\Econometrics I\Seminars\Seminar 6\Data\New data\hh4b_new.dta" gen health_expenses=h403 if n4b==5 & h404==1 & h405==1 replace health_expenses=h403/12 if n4b==5 & h404==1 & h405==2 replace health_expenses=h403*47.01 if n4b==5 & h404==2 & h405==1 replace health_expenses=h403*47.01/12 if n4b==5 & h404==2 & h405==2