I have some variables named "x2000" "yz2001"... I want to transform them to "2000x", "2001yz"...
I used function "substr" first to get the years. Then I want to put these years in front of the letters that remain in the name of variables ("x", "yz",...).
I do not know how to get this remaining part. I tried the code below but it did not work.
Many thanks for your help.
I used function "substr" first to get the years. Then I want to put these years in front of the letters that remain in the name of variables ("x", "yz",...).
I do not know how to get this remaining part. I tried the code below but it did not work.
HTML Code:
foreach v of varlist _all {
local new = substr("`v'", -4, 4)
local old = `v'-`new'
rename `v' `new'`v'
}

Comment