}**sexofHRPgenc_gender=-1replacec_gender=0ifsexhrp==1replacec_gender=1ifsexhrp==2labvarc_gender"Constraint: Gender of HRP"labdefc_gender0"Male"1"Female"labvalc_genderc_gender**ageofHRP
* need to use 75+ as few 80+ after 2001-2
recode p396p (min/15= . ) (16/24 = 0) (25/34 = 1) (35/44 = 2) (45/54 = 3) ///
(55/64 = 4) (65/74 = 5) (75/max = 6), gen(c_age)
lab var c_age "Constraint: Age of HRP"
* NB for NI need to change these as Census categories are different. Why why why!?
label define c_age ///
0 "16-24" ///
1 "25-34" ///
2 "35-44" ///
3 "45-54" ///
4 "55-64" ///
5 "65-74" ///
6 "75+"
lab val c_age c_age
** number of rooms
*1,2,3,4+
recode a114 (1=0) (2=1) (3=2) (4=3) (5/max=4), gen(c_nrooms)
lab var c_nrooms "Constraint: number of rooms"
lab def c_nrooms 0 "1" 1 "2" 2 "3" 3 "4" 4 "5+"
lab val c_nrooms c_nrooms
** Number of residents per household
recode a049 (1=0) (2=1) (3=2) (4=3) (5/max=4), gen(c_npersons)
lab var c_npersons "Constraint: number of persons in household (all ages)"
lab def c_npersons 0 "1" 1 "2" 2 "3" 3 "4" 4 "5+"
lab val c_npersons c_npersons
** Number of earners
recode a054 (0=0) (1=1) (2=2) (3/max=3), gen(c_nearners)
lab var c_nearners "Constraint: number of earners in household"
lab def c_nearners 0 "0" 1 "1" 2 "2" 3 "3+"
lab val c_nearners c_nearners
** Cars and vans.
* Object=
* 0 None
* 1 One
* 2 'Two or more'.
*has 1-12 so need to recode.
recode a124 (0=0) (1=1) (2/12=2), gen(c_ncars)
lab var c_ncars "Constraint: cars and vans"
lab define c_ncars 0 None 1 One 2 "Two or more"
lab val c_ncars c_ncars
*tab a124 c_cars
** Tenure.
* Object =
* 0 'Owned'
* 1 'Rent from council'
* 2 'Social rent'
* 3 'Private rent' - incl rent-free
*use a121.
recode a121 (5/7=0) (1=1) (2=2) (3/4 8=3), gen(c_tenure)
lab var c_tenure "Constraint: tenure"
lab define c_tenure 0 "Owned" 1 "Rent from council" 2 "Social rent" 3 "Private rent incl rent free"
lab val c_tenure c_tenure
*tab a121 c_tenure
** employment status.
* Object =
* 0 'NS-SEC 1'
* 1 'NS-SEC 2'
* 2 'NS-SEC 3'
* 3 'Inactive'
* 4 'Retired'.
* need to combine these - a093 = activity, a094 = NS-SEC.
* ref ONS website.
* need to put a094 = 9,10,11 ('Never worked and long term unemployed',students, not stated) into 'inactive'
recode a094 (0/2=0) (3/4=1) (5/8=2) (9/12=3), gen(c_empl)
* the crosstab of a094 against a093 shows that some who are coded as
* retired/unoccupied (a093=4/5) have an NS-SEC code as they are recently
* retired/unoccupied (?). In this case we use the activity code not the NS-SEC code.
replace c_empl=3 if a093==7
replace c_empl=4 if a093==6
lab var c_empl "Constraint: employment status of HRP"
lab define c_empl 0 "NS-SEC 1" 1 "NS-SEC 2" 2 "NS-SEC 3" 3 "Inactive" 4 "Retired"
lab val c_empl c_empl
*tab a093 c_empl
*tab a094 c_empl
** Region.
* use gorx.
gen region = gorx
label define region 1 "North East" 2 "North West & Merseyside" 3 "Yorkshire and the Humber" ///
4 "East Midlands" 5 "West Midlands" 6 "Eastern" 7 "London" 8 "South East" ///
9 "South West" 10 "Wales" 11 "Scotland" 12 "Northern Ireland"
lab var region "Govt. Office Region"
lab val region region
** Number of children - 16 or younger.
*Object =
* 0 0
* 1 1
* 2 2+.
gen c_nchild = a040+a041+a042
* has 1, 2 and more than 2 - so needs recoding.
recode c_nchild (0=0) (1=1) (2/max=2)
lab var c_nchild "Constraint: number of children"
lab define c_nchild 0 None 1 One 2 "Two or more"
lab val c_nchild c_nchild
* has 1, 2 and more than 2 - so needs recoding.
recodec_nchild(0=0)(1=1)(2/max=2)
labvarc_nchild"Constraint: number of children"
labdefinec_nchild0None1One2"Two or more"
labvalc_nchildc_nchild
genba_year=`y'
* construct list of vars to keep
...
...
@@ -181,7 +318,7 @@ if `do_extracts' {
* try as a varlist (forces expansion)
di"* Not found, expanding `v'"
capturenoisily{
* if variable really doesn't exist this throws an exception moves on
* if variable really doesn't exist this throws an exception & moves on
foreachvtofvarlist`v'{
captureconfirmvariable`vt'
if!_rc{
...
...
@@ -195,18 +332,71 @@ if `do_extracts' {
di"* dvhh: keeping case* ba_* c_* region weight* `keepvars'"
* dvper
di "* Need dvper file to count n children aged under 14 (for OECD equivalisation weight)"
* dvper
di"* Need dvper file to count n children aged under 14 (for OECD equivalisation weight)"
use"`efsd'/`y'/stata/dvper.dta",clear
* 2010 data = mixed/uppercase
if"`y'"=="2010"|"`y'"=="2011"|"`y'"=="2012"{
rename*,lower
}*keeponlyhrpskeepifa003==1
}
* keep only hrps
keepifa003==1
* Ethnicity
* NB a012 and a013 changed categories 2007->2008 to 0 = n/a, 1 = white, 2 = everyone else
* this still works, you can get detail from rawper.dta
recode a012p (1=0) (2/max=1), gen(c_white)
lab var c_white "Constraint: non-white HRP"
lab def c_white 0 "White HRP" 1 "Non-white HRP"
lab val c_white c_white
* if HRPs are not classified - they will show up as missing
* this still works, you can get detail from rawper.dta
recodea012p(1=0)(2/max=1),gen(c_white)
labvarc_white"Constraint: non-white HRP"
labdefc_white0"White HRP"1"Non-white HRP"
labvalc_whitec_white
* if HRPs are not classified - they will show up as missing
* construct list of vars to keep
* if dvper_keepvars is empty STATA will skip
...
...
@@ -349,11 +551,14 @@ if `do_extracts' {
keepcase*c_white
qui:compress
save"`efsd'/`y'/stata/dvper-temp.dta",replace
******************************
************
* Now c_lli but this time need to collapse it so we count the number in the household with/out lli
************
* Now c_lli but this time need to collapse it so we count the number in the household with/out lli
* and count the number of children of various ages