我写的.do是检查一些.dta文件中是否存在某些变量,以及检查这些变量是否存在某些值.但是,我的代码在遇到无效的变量名时停止执行.
我知道我混合Java和Stata编码,这是完全不合适的,但有什么方法可以做我喜欢的事情:
try {
su var1
local var1_mean=(mean)var1
local var1_min=(min)var1
local var1_max=(max)var1
...
}
catch (NoSuchVariableException e) {
System.out.println("Var1 does not exist")
}
// So that the code does not stop executing...?
Run Code Online (Sandbox Code Playgroud)