/* GGP User Generated Syntax - Number 1 ********************************************************************************************************************* ********************************************************************************************************************* Created by Judith Koops & Tom Emery (August 2015) PLEASE READ ME. Users should proceed with caution and ensure that the procedure has implemented correctly. Century Months express the date of an event in terms of the number of months past since January 1st 1900. This makes the file easy to use for analysing the life course as you can simply subtract one date from another in order to get the number of months between the two events. Before running the syntax you will need to open a 4.2 version of a wave 1 file and run then just run the syntax. The variables are then converted from month/year format to century month format (i.e. ahg6m_1 ahg6y_1 -> anhg6_CM). If you note any faults in the syntax please email ggp@nidi.nl. Syntax is provided for Wave 1 only. */ ** Wave 1 Century Month Creation *********************************************************************************************************************** by acountry, sort: egen modemonth = mode(amonth) replace amonth = modemonth if !missing(amonth) gen interview_CM = ((ayear - 1900)*12) + amonth lab var interview_CM "Interview Date in Century Months" drop modemonth **loops foreach x in ahg6 ahg7 a214 a216 a217 a220 a230 a232 a233 a234 a253 a255 a334 a335 a336 a344 a349 { forval y = 1(1)20 { set seed 1234567 capture confirm variable `x'm_`y' if !_rc { gen newvar = `x'm_`y' replace newvar = 12 if `x'm_`y' == 25 replace newvar = 8 + floor((3)*runiform() + 1) if `x'm_`y' == 24 // autumn set seed 1234567 replace newvar = 5 + floor((3)*runiform() + 1) if `x'm_`y' == 23 // summer set seed 1234567 replace newvar = 2 + floor((3)*runiform() + 1) if `x'm_`y' == 22 // spring set seed 1234567 replace newvar = floor((2)*runiform() + 1) if `x'm_`y' == 21 // winter months at the beginning of the year replace `x'm_`y' = newvar if !missing(newvar) & !missing(`x'y_`y') replace `x'm_`y' = floor((12)*runiform() + 1) if missing(`x'm_`y') & !missing(`x'y_`y') // generate random month if year is known drop newvar gen `x'_`y'_CM = ((`x'y_`y' - 1900)*12) + `x'm_`y' local j : variable label `x'm_`y' lab var `x'_`y'_CM "`j'" drop `x'y_`y' `x'm_`y' } } } forval y = 1(1)17 { set seed 1234567 replace ahg6_`y'_CM = (interview_CM-(12*ahg5_`y'+6)) + (floor((12)*runiform() - 6)) if acountry == 17 } **Standard foreach x in a107 a121 a150 a239a a239b a240 a301 a302b a303c a311 a314b a314d a315 a316c a371 a372b a373 a374c a603 a608 a610 a613b a614 a617b a619 a621 a803 a808 a812 a816 a822 a833 a871 a903 a907 a909 a911 a914 a941 a5116 a5117b { set seed 1234567 gen newvar = `x'm replace newvar = 12 if `x'm == 25 replace newvar = 8 + floor((3)*runiform() + 1) if `x'm == 24 // autumn set seed 1234567 replace newvar = 5 + floor((3)*runiform() + 1) if `x'm == 23 // summer set seed 1234567 replace newvar = 2 + floor((3)*runiform() + 1) if `x'm == 22 // spring set seed 1234567 replace newvar = floor((2)*runiform() + 1) if `x'm == 21 // winter months at the beginning of the year replace `x'm = newvar if !missing(newvar) & !missing(`x'y) replace `x'm = floor((12)*runiform() + 1) if missing(`x'm) & !missing(`x'y) // generate random month if year is known drop newvar gen `x'_CM = ((`x'y - 1900)*12) + `x'm local j : variable label `x'm lab var `x'_CM "`j'" drop `x'y `x'm }