help marktouse, help svymarktouse
-------------------------------------------------------------------------------

Title

marktouse -- Mark observations to be used

Syntax

marktouse markvar [varlist] [if] [in] [weight] [, label(label) zeroweight ]

svymarktouse markvar [varlist] [if] [in] [, label(label) ]

aweights, fweights, pweights, and iweights are allowed with marktouse; see weight. Time-series operators are allowed; see tsvarlist.

Description

marktouse creates a 0/1 marker variable recording which observations are to be used in subsequent commands. The marker variable is set to 1 in observations for which none of the specified variables contain missing, that satisfy the if and in qualifiers, and have a strictly positive, non-missing weight and is set to 0 in all other observations. Note that marktouse is intended for use in interactive mode or in do-files. Do not use marktouse within Stata programs. Use official marksample in Stata programs.

Working with a marker variable is useful if you want to ensure that all commands use the same observations. See "Stata tip 44: Get a handle on your sample" in the Stata Journal (in press). The procedure is to type

. marktouse markvar ... at the beginning of an analysis and include if markvar in all subsequent commands, as in

. regress ... if markvar

svymarktouse is like marktouse but, additionally, sets the marker variable to 0 wherever any of the survey-characteristic variables (previously set by svyset) contain missing. Essentially, svymarktouse is marktouse followed by svymarkout.

Warning: Do not use the if and in qualifiers in svymarktouse to restrict analyses to subpopulations. To compute estimates for subpopulations in complex survey data, use svy's subpop() option.

Options

label(label) attaches a label (up to 80 characters) to the marker variable.

zeroweight indicates that zero weights are not to be excluded.

Examples

. sysuse auto (1978 Automobile Data) . marktouse touse price weight rep78 (69 observations marked) . quietly regress price weight if touse . estimates store model1 . quietly xi: regress price weight i.rep78 if touse . estimates store model2 . estimates table model1 model2, stats(N) ---------------------------------------- Variable | model1 model2 -------------+-------------------------- weight | 2.0124198 2.440292 _Irep78_2 | 783.90092 _Irep78_3 | 1379.1152 _Irep78_4 | 2068.2672 _Irep78_5 | 3245.2724 _cons | 44.3284 -3000.4051 -------------+-------------------------- N | 69 69 ----------------------------------------

Returned results

r(N) scalar containing the number of marked observations r(markvar) macro containing the name of marker variable

References

Jann, B. (in press). Stata tip 44: Get a handle on your sample. The Stata Journal 7(2).

Author

Ben Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also see