我的目标是从一组1998-2008年的.mdb数据库文件中提取固定的若干列变量数据(比方说两列),做一个循环,但是由于stata中导入数据库文件的odbc load命令在执行前必须先用c清理内存,所以必须在循环中加入clear命令,我写的程序如下
local i=2001
while `i'<=2008{
odbc load id=FRDM name=B02,table("qy`i'") dsn("firm`i'")
save m`i'.10.dta
clear
local i=`i'+1
}
运行后错误信息如下
file m2001.10.dta saved
variable FRDM not found
r(683);
clear option to odbc command should just work. there is no reason this could fail.
run two consecutive odbc command with clear options in interactive mode and see if the second command runs fine. if not, trace, then paste the output.