Hi,
I wish to assign labels to multiple variables. I am aware of the elabel command in SSC, however I wanted to see how I could do it using loop. This is the code I used:
However, I get the error 'invalid syntax r(198)' when I run this code. Could someone explain to me why I am getting an error?
Thank you!
I wish to assign labels to multiple variables. I am aware of the elabel command in SSC, however I wanted to see how I could do it using loop. This is the code I used:
Code:
local varlist t_hhexp school_fees pvt_tuition t_childrensedu_exp
local labels "Household expenditure" ///
"School fees" ///
"Private tuition fees" ///
"Children's education expenditure"
local i = 1
foreach var of local varlist {
label variable `var' : word(`labels', `i')
local ++i
}
Thank you!

operator for introducing macro functions has to be used within local macro quotes (` '), and then you must use the macro word function, not the -gen- word() function. Finally, the -label var- command also requires that the variable label be enclosed in quotes and compound double quotes are safer if the label might itself contain quotes. So you need this:
Comment