I am new user to Stata. I am trying to take variables and label them as their variable names with a portion added to the front of them. I thought this would be simple code to write in a loop, but so far no luck.
This what the relevant chunk of attempted code looks like currently (it's only for one group of variables, I wanted to get it working before trying to apply it to the whole data set):
foreach var in varlist *cradj {
local labelname
`labelname' = `var'
label variable var "Credibility_Adjusted_MLR `labelname'"
}
Initially the code ran without errors, but didn't change anything. After some research and doing some tweaking to the code it now returns r(199) claiming that the third line does not make sense.
Thank you very much for any help!
This what the relevant chunk of attempted code looks like currently (it's only for one group of variables, I wanted to get it working before trying to apply it to the whole data set):
foreach var in varlist *cradj {
local labelname
`labelname' = `var'
label variable var "Credibility_Adjusted_MLR `labelname'"
}
Initially the code ran without errors, but didn't change anything. After some research and doing some tweaking to the code it now returns r(199) claiming that the third line does not make sense.
Thank you very much for any help!
Comment