Dear statalists,
I am currently working to extract specific variables from the British Househould Panel Survey (BHPS) to create a personalised dataset. Following the guidelines in an online manual (https://www.understandingsociety.ac....ta-version.pdf), I run the following code:
foreach w in h i j k l m n o p q r {
use `w'j1cssf `w'hid `w'j1rgsc `w'j1sec `w'j1seg `w'j1soc_cc `w'j1none using `w'indresp, clear
renpfix `w'
gen wave = strpos("abcdefghijklmnopqr","`w'")
sort hid
save $dir3/wavehon`w', replace
}
STATA produced the following output:
invalid 'h'
r(198);
I can't quite figure out what the problem is, as I don't think I specified a variable called "h" in my code.
Thank you very much in advance to anyone who will spend their time answering my question!
0 Response to invalid 'h' r(198) error in foreach loop
Post a Comment