Skip to content
Snippets Groups Projects
Commit 107a46f0 authored by Ben Anderson's avatar Ben Anderson
Browse files

fixed variable checking

parent 7a35be5b
No related branches found
No related tags found
No related merge requests found
......@@ -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'"
}
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment