Wednesday, January 04, 2006

Re: st: Checking if a file is svyset

Richard Williams <Richard.A.Williams.5@ND.edu> 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 jpitblado@stata.com * * 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?