Wednesday, January 04, 2006

Re: st: Checking if a file is svyset

Richard Williams <> 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 * * For searches and help try: * * *


Links to this post:

Create a Link

<< Home

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