I have three variables varA, varB and varC.
I attempted to first replace "missing" with NA in all three variables then add a label to all three variables.
First I replaced "missing" with NA:
local mylist1 varA-varC
foreach v1 of varlist `mylist1' {
replace `v1'="NA" if `v1' =="missing"
}
Now if I want to call the list again to add the same label to all three variables:
foreach v1 of varlist `mylist1' {
label var `v1' "testvaraible"
}
but I will get an error message saying :
varlist required
Could anyone explain why I can't recall the list?
For your first example, this would be legal syntax if the variables concerned were all string:
Notice the different punctuation for referring to a local macro (different left and right quotation marks) and the difference in placing braces.
It is difficult even to work out what you want in your second example, but the loop is over differing values of a local macro
v
which you never refer to inside the loop. Also, depending on the definition of the unspecified local macrotestvaraible
[sic], it is still puzzling why you would label three variables identically.You may need to be much more explicit about your data and exactly what you want if this does not answer the question. In particular, we can't see definitions for local macros
v1
andtestvaraible
.