Dear Stata users,
I need assistance in creating a separate list for translations in my dataset. Currently, my data includes variables x1, x2, and x3, x4, x5, x6. Among these variables, x2, x3,and x4 contain comments written in a foreign language. I would like to create two new columns, "name_var" and "trans," which will help me organize the translation process. In the "name_var" column, I want to display the variable name (e.g., x2), and in the "trans" column, I want to extract the specific phrase from x2 that requires translation.
My current code looks like this:
gen name_var = ""
gen trans = ""
local A x2 x3 x4
foreach var of varlist `A' {
replace name_var= "`var'"
replace trans = `var' if `var' != ""
}
However, this is not working for me since in the results I get only values from x4 and not from x2 and x3. Any guidance on how to achieve the desired result would be greatly appreciated.
Thank you!
I need assistance in creating a separate list for translations in my dataset. Currently, my data includes variables x1, x2, and x3, x4, x5, x6. Among these variables, x2, x3,and x4 contain comments written in a foreign language. I would like to create two new columns, "name_var" and "trans," which will help me organize the translation process. In the "name_var" column, I want to display the variable name (e.g., x2), and in the "trans" column, I want to extract the specific phrase from x2 that requires translation.
My current code looks like this:
gen name_var = ""
gen trans = ""
local A x2 x3 x4
foreach var of varlist `A' {
replace name_var= "`var'"
replace trans = `var' if `var' != ""
}
However, this is not working for me since in the results I get only values from x4 and not from x2 and x3. Any guidance on how to achieve the desired result would be greatly appreciated.
Thank you!
Comment