I am writing a .do
to check the existence of some variables in a number of .dta
files as well as to check the existence of certain values for those variables. However, my code stops executing as it encounters an invalid variable name.
I know I mix Java and Stata coding, and it is completely inappropriate, but is there any way I could do something like:
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...?
try
...i thought that this should be a natural way of checking a variable existence (maybe b/c i am more familiar w/java)...then i just got tired and frustrated...so i decided to ask REAL PROFESSIONALs :) – Conchology