Now you can simply read the first character of the file to determine the version. In addition to the version file version version 117 (current for Stata 13), the version will be saved in XML, so this method will need to be improved.
file open fhandle using dataset.dta, read binary file read fhandle %1s firstbytechar file close fhandle if "`firstbytechar'"=="<"{ di "Version 117" } else { mata: st_numscalar("v", ascii("`firstbytechar'")) di "Version " v }
source share