*************************************************************************** *********Merging service use data onto G2 and G1 parents population******** *************************************************************************** clear use E:\Data\workdata\705830\zic\sha\replication\data\grund_pop *merging parent identifiers merge 1:1 pnr using E:\Data\workdata\705830\zic\sha\replication\data\forældre_samlet keep if _merge==1|_merge==3 drop _merge *merging hospital use from 1991 onwards merge 1:1 pnr using E:\Data\workdata\705830\zic\sha\replication\data\syhb_samlet keep if _merge==1|_merge==3 drop _merge *merging data for social welfare benefits from 1991 onwards merge 1:1 pnr using E:\Data\workdata\705830\zic\sha\replication\data\dream_samlet_v2 keep if _merge==1|_merge==3 drop _merge *merging conviction data from 1990 onwards merge 1:1 pnr using E:\Data\workdata\705830\zic\sha\replication\data\krim_samlet keep if _merge==1|_merge==3 drop _merge *merging CPS data from 1990 onwards merge 1:1 pnr using E:\Data\workdata\705830\zic\sha\replication\data\forebyg_anbr_rep_samlet keep if _merge==1|_merge==3 drop _merge *merging mental health data from 1970 onwards merge 1:1 pnr using E:\Data\workdata\705830\zic\sha\replication\data\psyk_samlet_v2_70 keep if _merge==1|_merge==3 drop _merge *merging education data from 1984 onwards merge 1:1 pnr using E:\Data\workdata\705830\zic\sha\replication\data\education_pre keep if _merge==1|_merge==3 drop _merge save E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_pnr, replace /*merging service use for the years 2006-2016 to G1 mothers and fathers*/ *mothers clear use E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_pnr drop mor_id rename pnr mor_id rename indlag* indlag_mor* rename y2_samlet* y2_samlet_mor* rename samlet_con* samlet_con_mor* rename sum_af* sum_af_mor* rename sum_psyk* sum_psyk_mor* rename fodaar fodaar_mor rename ie_type ie_type_mor rename max_optal max_optal_mor rename kun_grund* kun_grund_mor* keep mor_id indlag_mor* y2_samlet_mor* samlet_con_mor* sum_af_mor* sum_psyk_mor* fodaar_mor ie_type_mor max_optal_mor kun_grund_mor* save E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_mor, replace *fathers use E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_pnr drop far_id rename pnr far_id rename indlag* indlag_far* rename y2_samlet* y2_samlet_far* rename samlet_con* samlet_con_far* rename sum_af* sum_af_far* rename sum_psyk* sum_psyk_far* rename fodaar fodaar_far rename ie_type ie_type_far rename max_optal max_optal_far rename kun_grund* kun_grund_far* format far_id %20.0f keep far_id indlag_far* y2_samlet_far* samlet_con_far* sum_af_far* sum_psyk_far* fodaar_far ie_type_far max_optal_far kun_grund_far* save E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_far, replace clear /*merging data for G2 and G1 mothers/fathers*/ use E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_pnr merge m:1 mor_id using E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_mor keep if _merge==1|_merge==3 gen mor_data=0 replace mor_data=1 if _merge==3 drop _merge merge m:1 far_id using E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_far keep if _merge==1|_merge==3 gen far_data=0 replace far_data=1 if _merge==3 drop _merge save E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_family, replace *********************************** *****historical G1 service use***** *********************************** *********************************************************************************************************** ***************merging on G1 service use from 1984 to 1994, except for mental health hospitalizations****** ******************** mental health data for the years 1984 to 1994 is added above************************* *********************************************************************************************************** clear use E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_family /*Merging G1 hospitalizations*/ merge m:1 far_id using E:\Data\workdata\705830\zic\sha\replication\data\samlet_hosp_aug2020_far keep if _merge==1|_merge==3 drop _merge merge m:1 mor_id using E:\Data\workdata\705830\zic\sha\replication\data\samlet_hosp_aug2020_mor keep if _merge==1|_merge==3 drop _merge /*Merging G1 convictions*/ merge m:1 mor_id using E:\Data\workdata\705830\zic\sha\replication\data\krim_samlet_aug2020_mor keep if _merge==1|_merge==3 drop _merge merge m:1 far_id using E:\Data\workdata\705830\zic\sha\replication\data\krim_samlet_aug2020_far keep if _merge==1|_merge==3 drop _merge /*Merging G1 social welfare benefits*/ merge m:1 mor_id using E:\Data\workdata\705830\zic\sha\replication\data\shss_samlet_mor keep if _merge==1|_merge==3 drop _merge merge m:1 far_id using E:\Data\workdata\705830\zic\sha\replication\data\shss_samlet_far keep if _merge==1|_merge==3 drop _merge forva x=1984/1994{ replace saml_k_f_mor`x'=0 if saml_k_f_mor`x'==. replace saml_k_f_far`x'=0 if saml_k_f_far`x'==. replace samlet_con_hist_mor`x'=0 if samlet_con_hist_mor`x'==. replace samlet_con_hist_far`x'=0 if samlet_con_hist_far`x'==. replace optal_hosp_mor`x'=0 if optal_hosp_mor`x'==. replace optal_hosp_far`x'=0 if optal_hosp_far`x'==. } /*constructing indicators of service use in period 1984 to 1994*/ gen samlet_shss_84_94_mor=saml_k_f_mor1984+saml_k_f_mor1985+saml_k_f_mor1986+saml_k_f_mor1987+saml_k_f_mor1988+saml_k_f_mor1989+ /// saml_k_f_mor1990+saml_k_f_mor1991+saml_k_f_mor1992+saml_k_f_mor1993+saml_k_f_mor1994 gen samlet_shss_84_94_far=saml_k_f_far1984+saml_k_f_far1985+saml_k_f_far1986+saml_k_f_far1987+saml_k_f_far1988+saml_k_f_far1989+ /// saml_k_f_far1990+saml_k_f_far1991+saml_k_f_far1992+saml_k_f_far1993+saml_k_f_far1994 gen samlet_con_84_94_mor=samlet_con_hist_mor1984+samlet_con_hist_mor1985+samlet_con_hist_mor1986+samlet_con_hist_mor1987+samlet_con_hist_mor1988+samlet_con_hist_mor1989+ /// samlet_con_hist_mor1990+samlet_con_hist_mor1991+samlet_con_hist_mor1992+samlet_con_hist_mor1993+samlet_con_hist_mor1994 gen samlet_con_84_94_far=samlet_con_hist_far1984+samlet_con_hist_far1985+samlet_con_hist_far1986+samlet_con_hist_far1987+samlet_con_hist_far1988+samlet_con_hist_far1989+ /// samlet_con_hist_far1990+samlet_con_hist_far1991+samlet_con_hist_far1992+samlet_con_hist_far1993+samlet_con_hist_far1994 gen samlet_hosp_84_94_mor=optal_hosp_mor1984+optal_hosp_mor1985+optal_hosp_mor1986+optal_hosp_mor1987+optal_hosp_mor1988+optal_hosp_mor1989+ /// optal_hosp_mor1990+optal_hosp_mor1991+optal_hosp_mor1992+optal_hosp_mor1993+optal_hosp_mor1994 gen samlet_hosp_84_94_far=optal_hosp_far1984+optal_hosp_far1985+optal_hosp_far1986+optal_hosp_far1987+optal_hosp_far1988+optal_hosp_far1989+ /// optal_hosp_far1990+optal_hosp_far1991+optal_hosp_far1992+optal_hosp_far1993+optal_hosp_far1994 save E:\Data\workdata\705830\zic\sha\replication\data\samlet_gini_family_histaug2020, replace