Hello,
I've been having some problems with loop syntax in Stata. I'm more familiar with R and python syntax.
Im using the code below to separate a string variable "B" after the word "area" and appending it to variable "C" because of some scraping issues with a few observations. I keep getting a syntax error no matter what I try doing. Please advise.
gen i = 1
while i <= _N & trim(B[i]) != "" {
tokenize B[i], parse("area")
gen newC`i' = word(B[i], 2, .)
replace C = C + " " + trim(newC`i') if newC`i' != ""
gen i = `i' + 1
}
I've been having some problems with loop syntax in Stata. I'm more familiar with R and python syntax.
Im using the code below to separate a string variable "B" after the word "area" and appending it to variable "C" because of some scraping issues with a few observations. I keep getting a syntax error no matter what I try doing. Please advise.
gen i = 1
while i <= _N & trim(B[i]) != "" {
tokenize B[i], parse("area")
gen newC`i' = word(B[i], 2, .)
replace C = C + " " + trim(newC`i') if newC`i' != ""
gen i = `i' + 1
}
Comment