假设有以下两个变量“a”和“b”

* Example generated by -dataex-. To install: ssc install dataex
clear
input float(a b)
1.1308583 2
-.3590008 6
  .4558003 5
-.8556925 7
-.58384866 6
2.7077494 3
-.13430178 0
1.0990763 8
-.8600481 8
.20633572 4
end
label var a "asset" 
label var b "board"

如何将变量名“a”和“b”替换为“asset”和“board”

方法:

foreach var of varlist ab { 
    local varlabel:variable 
    label`var'rename`var'`varlabel' 
}

转自:http://www.shujugo.cn/thread-84329-1-1.html