// ***************************************************************************** // PROGRAM - 10yrs HILDA calendar // Created by Jane Fry and Clare Boulton, Productivity Commission, Melbourne // August, 2013. //****************************************************************************** // THIS PROGRAM CREATES A DATA FILE IN WIDE FORMAT WITH FIVE MUTUALLY EXCLUSIVE // AND EXHAUSTIVE LABOUR MARKET AND EDUCATION ACTIVITY CATEGORIES FOR 120 MONTHS. // NOTE: THIS CODE IS DESIGNED TO WORK WITH HILDA RELEASE 10.0 (CONFIDENTIALISED) // DATA FILES. THE CODE WILL NEED TO BE ADAPTED TO EXTRACT THE CALENDAR DATA INTO // A SINGLE DATA FILE FOR OTHER RELEASES OF HILDA DATA. // This program creates 11 main output files: // "activity_wavea.dta" // "activity_waveb.dta" // "activity_wavec.dta" // "activity_waved.dta" // "activity_wavee.dta" // "activity_wavef.dta" // "activity_waveg.dta" // "activity_waveh.dta" // "activity_wavei.dta" // "activity_wavej.dta" // "activity_month_wide.dta"" clear all set maxvar 6000 set memory 600m set more off, permanently set autotabgraphs on set rmsg on // List of HILDA Variable names and descriptions // The '_' at the start of variable names indicates where the appropriate wave "letter" // should be. // ------------------------------ // RP (Responding person) file: // xwaveid - Cross wave ID // _hgage - DV: Age last birthday at June 30(wave a this is 2001) // [weighted topcode] // ahgsex : sex (male =1; female =2) //ENROLLED IN SCHOOL/EDUCATIONAL COURSE: //FT basis // _caeft01 - FG1 Calendar - FT Study - Early Jul 20YY // wave a this is 2000 // _caeft02 - FG1 Calendar - FT Study - Mid Jul 20YY // wave a this is 2000 // _caeft03 - FG1 Calendar - FT Study - Late Jul 20YY // wave a this is 2000 // _caeft04 - FG1 Calendar - FT Study - Early Aug 20YY // wave a this is 2000 // _caeft05 - FG1 Calendar - FT Study - Mid Aug 20YY // wave a this is 2000 // _caeft06 - FG1 Calendar - FT Study - Late Aug 20YY // wave a this is 2000 // _caeft07 - FG1 Calendar - FT Study - Early Sept 20YY // wave a this is 2000 // _caeft08 - FG1 Calendar - FT Study - Mid Sept 20YY // wave a this is 2000 // _caeft09 - FG1 Calendar - FT Study - Late Sept 20YY // wave a this is 2000 // _caeft10 - FG1 Calendar - FT Study - Early Oct 20YY // wave a this is 2000 // _caeft11 - FG1 Calendar - FT Study - Mid Oct 20YY // wave a this is 2000 // _caeft12 - FG1 Calendar - FT Study - Late Oct 20YY // wave a this is 2000 // _caeft13 - FG1 Calendar - FT Study - Early Nov 20YY // wave a this is 2000 // _caeft14 - FG1 Calendar - FT Study - Mid Nov 20YY // wave a this is 2000 // _caeft15 - FG1 Calendar - FT Study - Late Nov 20YY // wave a this is 2000 // _caeft16 - FG1 Calendar - FT Study - Early Dec 20YY // wave a this is 2000 // _caeft17 - FG1 Calendar - FT Study - Mid Dec 20YY // wave a this is 2000 // _caeft18 - FG1 Calendar - FT Study - Late Dec 20YY // wave a this is 2000 // _caeft19 - FG1 Calendar - FT Study - Early Jan 20YY // wave a this is 2001 // _caeft20 - FG1 Calendar - FT Study - Mid Jan 20YY // wave a this is 2001 // _caeft21 - FG1 Calendar - FT Study - Late Jan 20YY // wave a this is 2001 // _caeft22 - FG1 Calendar - FT Study - Early Feb 20YY // wave a this is 2001 // _caeft23 - FG1 Calendar - FT Study - Mid Feb 20YY // wave a this is 2001 // _caeft24 - FG1 Calendar - FT Study - Late Feb 20YY // wave a this is 2001 // _caeft25 - FG1 Calendar - FT Study - Early Mar 20YY // wave a this is 2001 // _caeft26 - FG1 Calendar - FT Study - Mid Mar 20YY // wave a this is 2001 // _caeft27 - FG1 Calendar - FT Study - Late Mar 20YY // wave a this is 2001 // _caeft28 - FG1 Calendar - FT Study - Early Apr 20YY // wave a this is 2001 // _caeft29 - FG1 Calendar - FT Study - Mid Apr 20YY // wave a this is 2001 // _caeft30 - FG1 Calendar - FT Study - Late Apr 20YY // wave a this is 2001 // _caeft31 - FG1 Calendar - FT Study - Early May 20YY // wave a this is 2001 // _caeft32 - FG1 Calendar - FT Study - Mid May 20YY // wave a this is 2001 // _caeft33 - FG1 Calendar - FT Study - Late May 20YY // wave a this is 2001 // _caeft34 - FG1 Calendar - FT Study - Early Jun 20YY // wave a this is 2001 // _caeft35 - FG1 Calendar - FT Study - Mid Jun 20YY // wave a this is 2001 // _caeft36 - FG1 Calendar - FT Study - Late Jun 20YY // wave a this is 2001 // PT basis // _caept01 - FG1 Calendar - PT Study - Early Jul 20YY // wave a this is 2000 // _caept02 - FG1 Calendar - PT Study - Mid Jul 20YY // wave a this is 2000 // _caept03 - FG1 Calendar - PT Study - Late Jul 20YY // wave a this is 2000 // ... // _caept34 - FG1 Calendar - PT Study - Early Jun 20YY // wave a this is 2001 // _caept35 - FG1 Calendar - PT Study - Mid Jun 20YY // wave a this is 2001 // _caept36 - FG1 Calendar - PT Study - Late Jun 20YY // wave a this is 2001 // EMPLOYED // job 1: // _caj0101 - FG1 Calendar - Job 1 - Early Jul 20YY // wave a this is 2000 // _caj0102 - FG1 Calendar - Job 1 - Mid Jul 20YY // wave a this is 2000 // _caj0103 - FG1 Calendar - Job 1 - Late Jul 20YY // wave a this is 2000 // ... // _caj0134 - FG1 Calendar - Job 1 - Early Jun 20YY // wave a this is 2001 // _caj0135 - FG1 Calendar - Job 1 - Mid Jun 20YY // wave a this is 2001 // _caj0136 - FG1 Calendar - Job 1 - Late Jun 20YY // wave a this is 2001 // job 2: // _caj0201 - FG1 Calendar - Job 2 - Early Jul 20YY // wave a this is 2000 // ... //job 12: // _caj1201 - FG1 Calendar - Job 12 - Early Jul 20YY // wave a this is 2000 // ...to job 12 late jun 2001 (_caj1236) // UNEMPLOYED // _caune01 - FG1 Calendar - Not employed but looking for work - Early Jul 20YY // wave a this is 2000 // _caune02 - FG1 Calendar - Not employed but looking for work - Mid Jul 20YY // wave a this is 2000 // _caune03 - FG1 Calendar - Not employed but looking for work - Late Jul 20YY // wave a this is 2000 // ... // _caune34 - FG1 Calendar - Not employed but looking for work - Early Jun 20YY // wave a this is 2001 // _caune35 - FG1 Calendar - Not employed but looking for work - Mid Jun 20YY // wave a this is 2001 // _caune36 - FG1 Calendar - Not employed but looking for work - Late Jun 20YY // wave a this is 2001 // NOT IN THE LABOUR FORCE // _canlf01 - FG1 Calendar - Not employed and not looking for work - Early Jul 20YY // wave a this is 2000 // _canlf02 - FG1 Calendar - Not employed and not looking for work - Mid Jul 20YY // wave a this is 2000 // _canlf03 - FG1 Calendar - Not employed and not looking for work - Late Jul 20YY // wave a this is 2000 // ... // _canlf34 - FG1 Calendar - Not employed and not looking for work - Early Jun 20YY // wave a this is 2001 // _canlf35 - FG1 Calendar - Not employed and not looking for work - Mid Jun 20YY // wave a this is 2001 // _canlf36 - FG1 Calendar - Not employed and not looking for work - Late Jun 20YY // wave a this is 2001 // ******************************************************************************************************* // CREATE SEPARATE WIDE FORMAT CALENDARS FOR EACH WAVE // ******************************************************************************************************* foreach w in a b c d e f g h i j { use "Rperson_`w'100c.dta", clear //STEP 1: generate indicator activity variables. (at this stage, not mutually exclusive) // unemployment and NILF indicator variables are already in the HILDA calendar // (acaune01 ... acaune36; acanlf01 ... acanlf36) //create an indicator variable (aedupart01...aedupart36) for participating in any education // (school or post-school; PT or FT) // Note that at this stage, those enrolled in education will also include some who have a job. // Will separate students with and without a job in step 2. foreach y in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 /// 31 32 33 34 35 36 { generate `w'edupart`y' =0 // this will include both 'no' and 'not asked' replace `w'edupart`y' = 1 if `w'caeft`y' ==1 | `w'caept`y'==1 } forvalues y =1/9 { rename `w'edupart0`y' `w'edupart`y' } //create an indicator variable (aemployed01...aemployed36) for employed in at least one job foreach y in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 /// 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 { generate `w'employed`y' =0 replace `w'employed`y' =1 if `w'caj01`y' ==1 | `w'caj02`y' ==1 | /// `w'caj03`y' ==1 | `w'caj04`y' ==1 |`w'caj05`y' ==1 | /// `w'caj06`y' ==1 | `w'caj07`y' ==1 | `w'caj08`y' ==1 | /// `w'caj09`y' ==1 | `w'caj10`y' ==1 |`w'caj11`y' ==1 |`w'caj12`y' ==1 } // rename emp variables so that they have suffixes that can be treated as numbers forvalues y =1/9 { rename `w'employed0`y' `w'employed`y' } // rename unemp variables so that they have suffixes that can be treated as numbers forvalues y =1/9 { rename `w'caune0`y' `w'caune`y' } // rename nilf variables so that they have suffixes that can be treated as numbers forvalues y = 1/9 { rename `w'canlf0`y' `w'canlf`y' } //STEP 2: create mutually exclusive and exhaustive, activity indicator variables // for each month third // 1st activity category: in education only (not working, but can be either // unemployed or NILF while studying) // need to exclude those also in employment forvalues y =1/36 { generate `w'eduonly`y' = `w'edupart`y' replace `w'eduonly`y' =0 if `w'employed`y' ==1 //those who are studying and also working // are removed from this indicator } // 2nd activity category: in education and also employed forvalues y =1/36 { generate `w'eduemp`y' = 0 replace `w'eduemp`y' = 1 if `w'employed`y' ==1 & `w'edupart`y'==1 } // 3rd activity category: employed only // need to exclude those also in education forvalues y =1/36 { generate `w'emponly`y' = `w'employed`y' replace `w'emponly`y' =0 if `w'edupart`y' ==1 // those who are employed and also studying // are removed from this indicator } // 4th activity category: unemployed (and not studying) //remove students and employed from unemployed category forvalues y =1/36 { recode `w'caune`y' -1 =0 replace `w'caune`y'=0 if `w'edupart`y'==1 | `w'employed`y'==1 } // 5th activity category: not in labour force (and not studying) //create not in labour force (and not participating in education or training) variable forvalues y =1/36 { generate `w'nilf`y'=0 replace `w'nilf`y'=1 if `w'canlf`y'==1 & `w'edupart`y' !=1 & /// `w'employed`y'!=1 & `w'caune`y' !=1 } //STEP 3: Generate monthly activity variables //generate activity variables with values to be filled in below: forvalues y=1/12 { generate `w'activity`y' =. } //define label for activity variables label define activity 1 "Study only" 2 "Work & study" 3 "Work only" /// 4 "Unemployed" 5 "NILF" local i=1 local j=2 // these three local macros represent the month thirds in each month local k=3 forvalues l=1/12 { replace `w'activity`l' = 1 if `w'eduonly`i' ==1 | `w'eduonly`j' ==1 | `w'eduonly`k' ==1 //study only replace `w'activity`l' = 2 if `w'eduemp`i' ==1 | `w'eduemp`j' ==1 | `w'eduemp`k' ==1 // work & study replace `w'activity`l' = 2 if `w'activity`l' ==1 & `w'emponly`i' ==1 replace `w'activity`l' = 2 if `w'activity`l' ==1 & `w'emponly`j' ==1 replace `w'activity`l' = 2 if `w'activity`l' ==1 & `w'emponly`k' ==1 replace `w'activity`l' = 3 if `w'activity`l' == . & `w'emponly`i'==1 // work only replace `w'activity`l' = 3 if `w'activity`l' == . & `w'emponly`j'==1 replace `w'activity`l' = 3 if `w'activity`l' == . & `w'emponly`k'==1 replace `w'activity`l' = 4 if `w'activity`l' == . & `w'caune`i'==1 // unemp replace `w'activity`l' = 4 if `w'activity`l' == . & `w'caune`j'==1 replace `w'activity`l' = 4 if `w'activity`l' == . & `w'caune`k'==1 replace `w'activity`l' = 5 if `w'activity`l' ==. // NILF label values `w'activity`l' activity local i=`i'+3 local j=`j'+3 // move to the next set of month thirds. local k=`k'+3 } //STEP 4: Create wide dataset for each wave, save to folder. keep xwaveid `w'hgage `w'activity* local wnum = strpos("abcdefghij","`w'") local j= (12*`wnum')-11 forvalues i =1/12 { rename `w'activity`i' activity`j' local j= (12*`wnum')-11 +`i' } // Activities are now contained in variables activity1 - activity120 // (ie. an activity variable for each month; split into one file per year) // with values 1 - 5 indicating what the activity was. save "activity_wave`w'", replace } //STEP 5: include other variable(s) from wave 1 e.g. gender (ahgsex). Add // other variables as appropriate. use "Rperson_a100c.dta", clear keep xwaveid ahgsex sort xwaveid merge 1:1 xwaveid using "activity_wavea.dta" keep if _merge==3 drop _merge save "activity_wavea.dta", replace //STEP 6: merge 10 waves together to form a wide dataset of activities. use "activity_wavea.dta", clear foreach w in b c d e f g h i j { sort xwaveid merge 1:1 xwaveid using "activity_wave`w'.dta" keep if _merge==3 drop _merge `w'hgage // drop unnecessary variables } // generate age group segments generate w1age=. replace w1age=1 if ahgage >=15 & ahgage <25 // youths replace w1age=2 if ahgage >=25 & ahgage <40 // young adults replace w1age=3 if ahgage >=40 & ahgage <55 // mature adults replace w1age=4 if ahgage >=55 & ahgage <65 // seniors label define wave1age 1 "youths" 2 "young adults" 3 "mature adults" 4 "seniors" label values w1age wave1age save "activity_month_wide.dta", replace