// Creates scdassat_dv AND scdascoh_dv // INPUT FILE - w_indresp.dta // OUTPUT FILE - w_scdas_dv.dta // WRITE FILEPATH WHERE YOU HAVE DOWNLOADED THE DATA global in "" // WRITE FILEPATH WHERE YOU WOULD LIKE TO SAVE THE OUTPUT FILE global outpath "" // 1 is for BHPS, 2 is for UKHLS global cohort "2" foreach w in a c e g i k { // INCLUDE WAVE LETTERS FOR THE WAVES NEEDED global wave "`w'_" global num=strpos("abcdefghijklmnopqrstuvwxyz","`w'") global dta "" global waveno=$num global inpath "${in}/bhps_w${num}" if $cohort==2 { global waveno=$num+18 global inpath "${in}/ukhls" } use "${inpath}/${wave}indresp${dta}", clear isvar ${wave}scdassat_dv ${wave}scdascoh_dv drop `r(varlist)' preserve foreach x in screlparei screlparcd screlparwt screlpards screlparrg screlparar screlparir screlparks { gen `x'=${wave}`x'-1 if ${wave}`x'>=1 replace `x'=. if ${wave}`x'<0 } recode ${wave}scparoutint 5=0 4=1 3=2 2=3 1=4 else=., gen(scparoutint) egen nomiss=robs(screlpards screlparrg screlparar screlparir) egen ${wave}scdassat_dv=rsum(screlpards screlparrg screlparar screlparir) if nomiss==4 lab var ${wave}scdassat_dv "Dyadic Adjustment Scale: Relationship satisfaction subscale" lab def ${wave}scdassat_dv -9"missing or wild" -8"inapplicable" -7"proxy respondent" 0"lowest level of satisfaction" 20"highest level of satisfaction", replace lab val ${wave}scdassat_dv ${wave}scdassat_dv cap drop nomiss egen nomiss=robs(scparoutint screlparwt screlparei screlparcd) egen ${wave}scdascoh_dv=rsum(scparoutint screlparwt screlparei screlparcd) if nomiss==4 lab var ${wave}scdascoh_dv "Dyadic Adjustment Scale: Relationship cohesion subscale" lab def ${wave}scdascoh_dv -9"missing or wild" -8"inapplicable" -7"proxy respondent" 0"lowest level of cohesion" 19"highest level of cohesion", replace lab val ${wave}scdascoh_dv ${wave}scdascoh_dv for var ${wave}scdassat_dv ${wave}scdascoh_dv: recode X .=-9 for var ${wave}scdassat_dv ${wave}scdascoh_dv: recode X -9=-7 if ${wave}ivfio==2 for var ${wave}scdassat_dv ${wave}scdascoh_dv: recode X -9=-8 if ${wave}screlparei==-8 // if first q in battery inapplicable, all inapplicable if ${waveno}==19 { recode ${wave}scdassat_dv -9=-8 if a_scmolwp==2 | (a_scmolwp==-9 & a_ppno==0) recode ${wave}scdascoh_dv -9=-8 if a_scmolwp==2 | (a_scmolwp==-9 & a_ppno==0) for var ${wave}scdassat_dv ${wave}scdascoh_dv: recode X -9=-8 if ${wave}scflag_dv==0 } keep pidp ${wave}scdassat_dv ${wave}scdascoh_dv if ${waveno}==21 { drop ${wave}scdascoh_dv // scparoutint has different code frame in w3, see dr# } lab dat "Dyadic Adjustment Scale: Subscales, derived variables" compress save "${outpath}/${wave}scdas_dv", replace restore }