Dear Statalisters,
I would like to replace foreign alphabet letters by English alphabet letters in my dataset. I have 5 variables and the observations are all string variables written in Foreign alphabet.
I am using the commands below. However, I am getting this error message : "invalid syntax".
It looks like I am writing " local wrongVowel `:word `i' of `wrongVowels'' " in a wrong way.
Which codes should I run, and how can I run them?
Thank you in advance for your help
Marina
I would like to replace foreign alphabet letters by English alphabet letters in my dataset. I have 5 variables and the observations are all string variables written in Foreign alphabet.
I am using the commands below. However, I am getting this error message : "invalid syntax".
Code:
local wrongVowels "ệ ê ũ à ã â Đ ư ơ ò ì ợ ớ ị ỳ ủ ẩ ú ọ ô ổ á ấ ằ ằ ả ắ ạ ữ "
local correctVowels "e e u a a a D u o o i o o i y u a u o o o a a a a a a a u"
local nVowels : word count("`wrongVowels'")
levelsof district, local(distobserv)
* For each variable, replace wrong characters with correct/simplified ones
foreach l of `distobserv' {
forvalues i = 1/`nVowels' {
local wrongVowel `:word `i' of `wrongVowels''
local correctVowel `:word `i' of `correctVowels''
replace `l' = subinstr(`l',"`wrongVowel'" ,"`correctVowel'" ,.)
}
}
Which codes should I run, and how can I run them?
Thank you in advance for your help
Marina

Comment