|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Typo in the .dta description
Sergiy Radyakin <[email protected]> posted a question about the internal
structure of Stata's dta-files. In it Sergiy asked which data characteristics
to set so that Stata's -svy- commands will recognize that the data was
-svyset- using only a sampling weight variable:
> Another question is regarding the weighting scheme saved in the
> .dta-files. Although weighting is not a part of the file-format
> specification and the scheme is saved by an .ado file for svy commands
> in the dataset characteristics, it would be nice to have a
> description, of which exactly dataset characteristics must be set by
> an external program, so that Stata recognizes the weighting
> automatically.
Stata's -svyset- command has gone through a few design updates, and the
current design does not lend itself to Sergiy's simple request. Fortunately
an earlier design does and the -svy- commands are backward compatible.
The simplest way for an external program to generate a dataset so that it will
be recognized as -svyset- with -pweight-s is to specify the following data
characteristics:
characteristic value
---------------------------------------------------------------------
_dta[_svy] "set"
_dta[pweight] variable name containing the sampling weights
Note that abbreviating the name of the weight variable will cause problems for
Stata users that set variable abbreviation off (see -help set varabbrev-).
Here is a simple example in Stata that sets the characteristics directly
instead of using the -svyset- command.
***** BEGIN:
. sysuse auto
(1978 Automobile Data)
. svyset
no survey characteristics are set
. char _dta[_svy] "set"
. char _dta[pweight] "displacement"
. svyset
pweight: displacement
VCE: linearized
Single unit: missing
Strata 1: <one>
SU 1: <observations>
FPC 1: <zero>
. svy: mean mpg turn
(running mean on estimation sample)
Survey: Mean estimation
Number of strata = 1 Number of obs = 74
Number of PSUs = 74 Population size = 14600
Design df = 73
--------------------------------------------------------------
| Linearized
| Mean Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
mpg | 19.42267 .6027065 18.22148 20.62386
turn | 41.21781 .5582319 40.10525 42.33036
--------------------------------------------------------------
***** END:
--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/