Thursday, December 29, 2005

st: Checking if a file is svyset

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: Richard.A.Williams.5@ND.Edu 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/


Tag:


Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?