diff --git a/ONS-UK-EFS-time-series-extract.do b/ONS-UK-EFS-time-series-extract.do index 5229bb0118724fdb4a363f2f6e3bafd255be83af..b5351c9a86d21693512422f1cdff7b9713494d3b 100755 --- a/ONS-UK-EFS-time-series-extract.do +++ b/ONS-UK-EFS-time-series-extract.do @@ -78,11 +78,14 @@ local do_extracts 1 * -> dvhh file * basic weighting & consumption expenditure codes -local dvhh_keepvars = "p60*t p61*t p630* p396*" +* p60*t p61*t p630* +local dvhh_keepvars = "" * needed for income equivalisation later -local dvhh_keepvars = "`dvhh_keepvars' incanon a055 g018 g019 p116* p344* p389*" +local dvhh_keepvars = "`dvhh_keepvars' incanon a055 g018 g019 p116* p344* p389* p396*" * DEMAND 2.3 (older people mobile lives) local dvhh_keepvars = "`dvhh_keepvars' b480 b481 b485 cc5413t c73312t" // overseas travel expenditures +* DEMAND 3.1 (adapting infrastructures) +local dvhh_keepvars = "`dvhh_keepvars' a103 a108 a128 a130 a15* a16* a1701 a1711" // energy using appliances * -> dvper file local dvper_keepvars = "case" @@ -166,14 +169,27 @@ if `do_extracts' { * construct list of vars to keep * if dvhh_keepvars is empty STATA will skip local keepvars = "" - foreach v of varlist `dvhh_keepvars' { + foreach v of local dvhh_keepvars { + di "* Testing for existence of `v'" capture confirm variable `v' if !_rc { - *di "* found `v'" + di "* found `v'" local keepvars = "`keepvars' `v'" } else { - di in red "`v' does not exist in `y' - will be missing" + * exact string not found as a variable, could be because it needs expansion + * try as a varlist (forces expansion) + di "* Not found, expanding `v'" + capture noisily { + * if variable really doesn't exist this throws an exception moves on + foreach vt of varlist `v' { + capture confirm variable `vt' + if !_rc { + di "* -> found `vt'" + local keepvars = "`keepvars' `vt'" + } + } + } } }