What is the best way for a program to check if a file is
svyset? Further, is it possible to check whether a file was svyset
under version 9 (when the format changed) as opposed to an earlier version?
Right now my program has code like this:
quietly version `c(stata_version)': svyset
if "`r(settings)'" == ", clear(all)" {
display as error "svy option requires the
data to be svyset"
exit 198
}
This checks whether the file is svyset. If the file is svyset under
Stata 9 and you are running Stata 8.2, you get the error message.
Later on I have
quietly version 8.2: svyset
if "`r(settings)'" == ", clear(all)" local svy9 "svy9"
If you are running Stata 9, this will tell you that the file was
svyset under Stata 9 (because 9.0+ could tell that it was svyset but
8.2 cannot.)
This seems a little clunky though, and depends on the value of
r(settings), and I am not sure you can count on that forever being the same.