1# wonway
// id是string,然后正常是6位的(包括数字和字母),发现有些id是少于六位,原因是前面的0没有了
// 比如"0025K4",写成了"25K4"。或者"00024J",写成"24J"
// 将少于六位的全部在前面补0,使其变成6位
set more off
set linesize 255
clear
cd c:\data
input str6 id
4
K4
5K4
25K4
125K4
0125K4
end
gen str6 id_rvsd = id
replace id_rvsd = id if length(id) == 6
replace id_rvsd = "0" + id if length(id) == 5
replace id_rvsd = "00" + id if length(id) == 4
replace id_rvsd = "000" + id if length(id) == 3
replace id_rvsd = "0000" + id if length(id) == 2
replace id_rvsd = "00000" + id if length(id) == 1
list