Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Typo in the .dta description


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: Typo in the .dta description
Date   Thu, 10 Jan 2008 10:57:18 -0500

I would like to thank William and Jeff from Stata, Corp for their
prompt answers to my questions regarding the Stata data file format.

In particular, William directly points at my mistake, that storing a
64-bit wide integer is done in a natural byte order in my compiler: an
assignment

int64((@StataMissing)^)=$e07f

yields in fact the opposite byte order in the stored value, since I am
working on a LoHi machine and the hexadecimal values reported in the
LoHi-column of the mentioned table are the memory dumps, not the
values that one assigns in statements similar to above.

William further suggests the robust way of assigning missing values,
which uses addressing the values byte-by-byte.

In the end, my code for assigning a system-missing value to the double
precision variable on a 32-bit LoHi machine looks like this:

asm
    lea eax,Stata_SystemMissingHere   // Value for Stata . missing value
    mov [eax],$00000000
    mov [eax+04],$7FE00000
end;

Using 64-bit integers in the compiler I am using will yield
essentially the same code.

Thank you,
   Sergiy Radyakin








On 1/9/08, Jeff Pitblado, StataCorp LP <[email protected]> wrote:
> 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/
>
*
*   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