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

Re: st: Checking if a file is svyset


From   [email protected] (Jeff Pitblado, StataCorp LP)
To   [email protected]
Subject   Re: st: Checking if a file is svyset
Date   Wed, 04 Jan 2006 16:46:53 -0600

Richard Williams <[email protected]> asks how to check the dataset
in memory for the survey settings from -svyset-:

> What is the best way for a program to check if a file is svyset?

In your estimation command, when the specified options require the data to be
-svyset-, use the -_svy_newrule- command.  Just make sure you call it under
the correct version control:

	program mycmd, eclass ...
		version 8.2
		local caller : di "version " string(_caller()) ":"
		...
		if "`svy'" != "" {
			`caller' _svy_newrule		// check for settings
		}
		...
	end

-_svy_newrule- is a (perhaps misnamed) not-documented command that will report
an error message if the data is not -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?

Under version control less than 9, -svyset- returns "set" in r(_svy) when the
data is -svyset- under the old survey design characteristics.

In Stata 9 (under version 9.0 and up) -svyset- stores ", clear" in r(settings)
when the data is not -svyset-.

--Jeff
[email protected]
*
*   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