Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Checking if a file is svyset


From   Richard Williams <[email protected]>
To   [email protected]
Subject   st: Checking if a file is svyset
Date   Thu, 29 Dec 2005 12:28:38 -0500

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.

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index