Skip to content

Syntax

Big 5 personality variables

Creates big5a_dv, big5dv, big5e_dv, big5n_dv, big5o_dv

// Creates w_big5_dv -   Big 5 personality variables: c_big5a_dv c_big5c_dv c_big5e_dv c_big5n_dv c_big5o_dv
// INPUT FILE - w_indresp.dta 
// OUTPUT FILE - w_big5_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 c { // 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
drop *_big5*

/*-------------ORIGINAL CODE--------------*/
/* This programme derives the big 5 personality marker from 15 items with the ofllowing root names
_scptrt5a1 resp. is sometimes rude to others
_scptrt5c1 resp. does a thorough job
_scptrt5e1 resp. is talkative
_scptrt5n1 resp. worries a lot
_scptrt5o1 resp. is original, come up with ideas
_scptrt5a2 resp. has a forgiving nature
_scptrt5c2 resp. tends to be lazy
_scptrt5e2 resp. is outgoing, sociable
_scptrt5n2 resp. gets nervous easily
_scptrt5o2 resp. values artistic, aesthetic experiences
_scptrt5a3 resp. considerate & kind
_scptrt5c3 resp. does things efficiently
_scptrt5e3 resp. is reserved
_scptrt5n3 resp. is relaxed, handles stress well
_scptrt5o3 resp. has an active imagination
*/

* reverse code some components of big five
gen iemb=(${wave}scptrt5a1==-10 | ${wave}scptrt5a1==-11) // needed to recode -9 to -8 for content not in iemb
if $cohort==1 {
 gen SC1=(${wave}ivsc==1)
 }
else {
}
for var ${wave}scptrt5*: replace X=. if X<0
for var ${wave}scptrt5a1 ${wave}scptrt5c2 ${wave}scptrt5e3 ${wave}scptrt5n3: omscore X

* impute mean of two reports for cases with just one item per trait missing
egen m_a=rowmiss(rr_${wave}scptrt5a1 ${wave}scptrt5a2 ${wave}scptrt5a3)
egen s_a=rmean(rr_${wave}scptrt5a1 ${wave}scptrt5a2 ${wave}scptrt5a3) if m_a==1
for var rr_${wave}scptrt5a1 ${wave}scptrt5a2 ${wave}scptrt5a3: replace X=s_a if X==. & m_a==1

egen m_c=rowmiss(${wave}scptrt5c1 rr_${wave}scptrt5c2 ${wave}scptrt5c3)
egen s_c=rmean(${wave}scptrt5c1 rr_${wave}scptrt5c2 ${wave}scptrt5c3) if m_c==1
for var rr_${wave}scptrt5c2 ${wave}scptrt5c1 ${wave}scptrt5c3: replace X=s_c if X==. & m_c==1

egen m_e=rowmiss(${wave}scptrt5e1 ${wave}scptrt5e2 rr_${wave}scptrt5e3)
egen s_e=rmean(${wave}scptrt5e1 ${wave}scptrt5e2 rr_${wave}scptrt5e3) if m_e==1
for var ${wave}scptrt5e1 ${wave}scptrt5e2 rr_${wave}scptrt5e3: replace X=s_e if X==. & m_e==1

egen m_n=rowmiss(${wave}scptrt5n1 ${wave}scptrt5n2 rr_${wave}scptrt5n3)
egen s_n=rmean(${wave}scptrt5n1 ${wave}scptrt5n2 rr_${wave}scptrt5n3) if m_n==1
for var ${wave}scptrt5n1 ${wave}scptrt5n2 rr_${wave}scptrt5n3: replace X=s_n if X==. & m_n==1

egen m_o=rowmiss(${wave}scptrt5o1 ${wave}scptrt5o2 ${wave}scptrt5o3)
egen s_o=rmean(${wave}scptrt5o1 ${wave}scptrt5o2 ${wave}scptrt5o3) if m_o==1
for var ${wave}scptrt5o1 ${wave}scptrt5o2 ${wave}scptrt5o3: replace X=s_o if X==. & m_o==1

gen ${wave}big5a_dv=round((rr_${wave}scptrt5a1 + ${wave}scptrt5a2 + ${wave}scptrt5a3)/3,1)
gen ${wave}big5c_dv=round((${wave}scptrt5c1 + rr_${wave}scptrt5c2 + ${wave}scptrt5c3)/3,1)
gen ${wave}big5e_dv=round((${wave}scptrt5e1 + ${wave}scptrt5e2 + rr_${wave}scptrt5e3)/3,1)
gen ${wave}big5n_dv=round((${wave}scptrt5n1 + ${wave}scptrt5n2 + rr_${wave}scptrt5n3)/3,1)
gen ${wave}big5o_dv=round((${wave}scptrt5o1 + ${wave}scptrt5o2 + ${wave}scptrt5o3)/3,1)
for var ${wave}big5*_dv: recode X (.=-9)
for var ${wave}big5*_dv: recode X (-9=-7) if ${wave}ivfio==2
for var ${wave}big5*_dv: recode X (-9=-8) if ${wave}scflag_dv~=1 | iemb==1
for var ${wave}big5*_dv: lab def X -9"missing", replace
for var ${wave}big5*_dv: lab def X  -8"inapplicable", add
for var ${wave}big5*_dv: lab def X  -7"proxy respondent", add
for var ${wave}big5*_dv: lab val X X
lab var ${wave}big5a_dv "Agreeableness" 
lab var ${wave}big5c_dv "Conscientiousness"
lab var ${wave}big5e_dv "Extraversion"
lab var ${wave}big5n_dv "Neuroticism"
lab var ${wave}big5o_dv "Openness" 

* Target variables
keep ${wave}hidp ${wave}pno ${wave}big5*_dv
sort ${wave}hidp ${wave}pno
lab dat "Big 5 personality traits, derived"
save "${outpath}/${wave}big5_dv", replace
}

Email newsletter

Sign up to our newsletter

Enter your email to receive our newsletter updates.