******************************************************************** * File HALCyon cortisol syntax_NSHD.do * BY Mike Gardner, University of Bristol * FOR HALCyon cross-cohort collaboration (funded by the New Dynamics of Ageing (RES-353-25-0001)) * DATASET MRC National Survey of Health and Development * Date Created 25/03/2010 * last modified 25/03/2010 * PURPOSE Cleans and derives cortisol variables ************************************************************************************* ************************************************************************************* * Cleans cortisol to less than 100nmol/L and derives morning, CAR and diurnaldrop* * Derives z scored cortisol measures and cortisol variables in quartiles * ************************************************************************************* **NSHD data had 9999 coded for unknown, 7777 for not attending clinic and 9998 for empty mvdecode cortt106, mv(9999) mvdecode cortt206, mv(9999) mvdecode cortt306, mv(9999) mvdecode cortt406, mv(9999) mvdecode cortt106, mv(7777) mvdecode cortt206, mv(7777) mvdecode cortt306, mv(7777) mvdecode cortt406, mv(7777) mvdecode cortt106, mv(9998) mvdecode cortt206, mv(9998) mvdecode cortt306, mv(9998) mvdecode cortt406, mv(9998) rename cortt306 cortisoltime1 rename cortt406 cortisoltime2 rename cortt106 cortisoltime3 rename cortt206 cortisoltime4 sum cortisoltime1 cortisoltime2 cortisoltime3 cortisoltime4 replace cortisoltime1=. if cortisoltime1>100 replace cortisoltime2=. if cortisoltime2>100 replace cortisoltime3=. if cortisoltime3>100 replace cortisoltime4=. if cortisoltime4>100 sum cortisoltime1 cortisoltime2 cortisoltime3 cortisoltime4 **Now generate cortisol variables **Average morning cortisol for waking and 30 mins after waking egen cortmornavg=rowmean(cortisoltime1 cortisoltime2) **Now generate CAR gen deltaavg = (cortisoltime2 - cortisoltime1) gen diurnaldropavg = (cortmornavg - cortisoltime4) **Lable cortisol variables label variable cortisoltime1 "Cortisol on waking" label variable cortisoltime2 "Cortisol 30 minutes after waking" label variable cortisoltime3 "Mid-morning clinic cortisol" label variable cortisoltime4 "Night time cortisol 9.30pm" label variable cortmornavg "Morning Cortisol" label variable deltaavg "CAR" label variable diurnaldropavg "Diurnal cortisol slope" **zscore cortisol variables zscore cortisoltime1 zscore cortisoltime2 zscore cortisoltime3 zscore cortisoltime4 zscore cortmornavg zscore deltaavg zscore diurnaldropavg **put cortisol variables into quartiles xtile morncortquart=cortmornavg, nq(4) table morncortquart, c(n cortmornavg min cortmornavg max cortmornavg) xtile nightcortquart=cortisoltime4, nq(4) table nightcortquart, c(n cortisoltime4 min cortisoltime4 max cortisoltime4) xtile nightcortbin=cortisoltime4, nq(2) xtile deltacortquart=deltaavg, nq(4) table deltacortquart, c(n deltaavg min deltaavg max deltaavg) xtile diurnalcortquart=diurnaldropavg, nq(4) table diurnalcortquart, c(n diurnaldropavg min diurnaldropavg max diurnaldropavg)