Hi everybody,

I'm trying to replace an existing variable label with a subtract of the existing varlabel (first nine characters) within a Stata loop:

my code looks like this:

foreach var of varlist _all {
local varlabel: var label `var'
local newname: substr(`varlabel',1,9)
label `var' `newname'
}

Then I receive the following error:
substr not allowed ??

Hope you can help

Kind regards Frank