Dear everyone! I want to use forecache to convert Excel files named by numbers into Chinese characters in batch. Specifically, it is uniformly named after the first observation value of the first variable. However, when looping to the seventh file, it cannot continue, and the contents of the table become null. I observed the first excel table and found a feature. Compared with other tables, the first observation value of the first variable in the table(1-7) contains a dun sign( can be seen in the appendix.1-7 全国、新疆及兵团国民经济主要指标指数). How to successfully name excel in Chinese.
My code is as follows:
cd E:\各类统计数据汇集\新疆生产建设兵团统计年鉴2021\table
local files: dir "." files "*.xls"
foreach file in `files'{
import excel using `file', clear
local a = A[1]
save "`a'",replace
}
But only 1-1 to 1-6 is OK. (file 1-1 年末单位数.dta not found)
file 1-1 年末单位数.dta saved
(22 vars, 24 obs)
(file 1-2 各师单位数.dta not found)
file 1-2 各师单位数.dta saved
(12 vars, 95 obs)
(file 1-3 主要年份国民经济和社会发展主要指标.dta not found)
file 1-3 主要年份国民经济和社会发展主要指标.dta saved
(7 vars, 64 obs)
(file 1-4 主要年份国民经济和社会发展主要比例和效益指标.dta not found)
file 1-4 主要年份国民经济和社会发展主要比例和效益指标.dta saved
(11 vars, 105 obs)
(file 1-5 主要年份国民经济和社会发展结构指标.dta not found)
file 1-5 主要年份国民经济和社会发展结构指标.dta saved
(9 vars, 47 obs)
(file 1-6 主要时期国民经济主要指标平均增长速度.dta not found)
file 1-6 主要时期国民经济主要指标平均增长速度.dta saved
The error is :
A not found
r(111);
end of do-file
r(111);
My code is as follows:
cd E:\各类统计数据汇集\新疆生产建设兵团统计年鉴2021\table
local files: dir "." files "*.xls"
foreach file in `files'{
import excel using `file', clear
local a = A[1]
save "`a'",replace
}
But only 1-1 to 1-6 is OK. (file 1-1 年末单位数.dta not found)
file 1-1 年末单位数.dta saved
(22 vars, 24 obs)
(file 1-2 各师单位数.dta not found)
file 1-2 各师单位数.dta saved
(12 vars, 95 obs)
(file 1-3 主要年份国民经济和社会发展主要指标.dta not found)
file 1-3 主要年份国民经济和社会发展主要指标.dta saved
(7 vars, 64 obs)
(file 1-4 主要年份国民经济和社会发展主要比例和效益指标.dta not found)
file 1-4 主要年份国民经济和社会发展主要比例和效益指标.dta saved
(11 vars, 105 obs)
(file 1-5 主要年份国民经济和社会发展结构指标.dta not found)
file 1-5 主要年份国民经济和社会发展结构指标.dta saved
(9 vars, 47 obs)
(file 1-6 主要时期国民经济主要指标平均增长速度.dta not found)
file 1-6 主要时期国民经济主要指标平均增长速度.dta saved
The error is :
A not found
r(111);
end of do-file
r(111);