Stata 15 help for svy_parsing


[P] svy parsing -- Check options for community-contributed commands used with the svy prefix


svy fits statistical models for complex survey data and can be used with community-contributed estimation commands that meet its programming properties; see program properties. Not all options of a given estimation command may be allowed with the svy prefix, so svy provides a way for estimation command programmers to check for these disallowed options. svy does this by looking for a program with a specific name to help validate the options specified on the prefixed command. The name of the syntax validation command is a function of the prefixed estimation as follows:

. svy: cmdname ... , options

The above command causes svy to look for a command named cmdname_svy_check and then to make the call

. cmdname_svy_check, vce(vcetype) options

if cmdname_svy_check exists. vcetype is empty by default but will contain the replication method, even if svyset, using the vce() option.


Suppose that we developed an estimation command and added support for svy. Let's assume our command is called myest and that there is an option called lrstats that is not allowed with the svy prefix. When svy is used with myest, svy will look for a program named myest_svy_check. If myest_svy_check exists, svy will call it with the options specified in the call to myest, along with the vce() option containing the VCE method that will be used. For example,

. svy: myest varlist

will make the call

. myest_svy_check, vce(linearized)

if myest_svy_check exists.

We mentioned that myest has option lrstats that is not allowed with svy, so our myest_svy_check has the following definition:

program myest_svy_check syntax [, vce(string) lrstats *] if "`lrstats'" != "" { di as err "option lrstats not allowed with svy `vce'" exit 198 } end

myest_svy_check specifically parses options vce() and lrstats, ignoring all other options. If lrstats is specified, then myest_svy_check reports an error explaining that lrstats is not allowed with svy.

The default VCE is vce(linearized), but svy will pass an empty vce() option if the default is not changed and svy linearized is not explicitly specified. svy will always pass the replication method being used in the vce() option, so we can disallow options based on the VCE method if possible.

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