📄 mark.hlp
字号:
{smcl}
{* 09feb2005}{...}
{cmd:help mark}, {cmd:help markout}, {cmd:help marksample}, {cmd:help markin}
{hline}
{title:Title}
{p2colset 5 17 19 2}{...}
{p2col :{hi:[P] mark} {hline 2}}Mark observations for inclusion{p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 19 2}{cmd:marksample} {it:lmacname} [{cmd:,} {cmdab:nov:arlist}
{cmdab:s:trok} {cmdab:zero:weight} {cmd:noby}]
{p 8 19 2}{cmd:mark}{space 5}{it:newmarkvar}
{ifin} {weight}
[{cmd:,} {cmdab:zero:weight} {cmd:noby}]
{p 8 19 2}{cmd:markout}{space 2}{it:markvar} {varlist} [{cmd:,}
{cmdab:s:trok}]
{p 8 19 2}{cmd:markin}{space 3}{ifin}
[{cmd:,}
{cmdab:n:ame}{cmd:(}{it:local_macro_name}{cmd:)}
{cmd:noby}]
{pstd}
{cmd:aweight}s, {cmd:fweight}s, {cmd:pweight}s, and {cmd:iweight}s are
allowed; see {help weight}.{p_end}
{pstd}
Time-series operators are allowed; see {help tsvarlist}.
{title:Description}
{pstd}
{cmd:marksample}, {cmd:mark}, and {cmd:markout} are for use in Stata programs.
They create a 0/1 variable recording which observations are to be used in
subsequent code. The idea is to determine the relevant sample early in the
code:
{cmd:program} ...
(parse the arguments)
(determine which observations are to be used)
{it:rest of code} ... {cmd:if} {it:to be used}
{cmd:end}
{pstd}
{cmd:marksample}, {cmd:mark}, and {cmd:markout} assist in this.
{cmd:program} ...
(parse the arguments)
{p 16 18 2} (use {cmd:mark*} to create temporary variable {cmd:`touse'} containing 0 or 1){p_end}
{it:rest of code} ... {cmd:if `touse'}
{cmd:end}
{pstd}
{cmd:marksample} is for use in programs where the arguments are parsed using
the {helpb syntax} command. {cmd:marksample} creates a temporary {cmd:byte}
variable, stores the name of the temporary variable in {it:lmacname}, and
fills in the temporary variable with 0s and 1s according to whether the
observation is used. This determination is made by accessing information
stored by {cmd:syntax} concerning the {it:varlist}, {cmd:if} {it:exp}, etc.
allowed by the program.
{pstd}
{cmd:mark} starts with an already created temporary variable name. It fills
in {it:newmarkvar} with 0s and 1s according to whether the observation should
be used according to the {it:weight}, {cmd:if} {it:exp}, and {cmd:in}
{it:range} specified. {cmd:markout} modifies the variable created by
{cmd:mark} by resetting it to contain 0 in observations that have missing
values recorded for any of the variables in {it:varlist}.
{pstd}
{cmd:marksample} is better than {cmd:mark} because there is less chance that
you will forget to include some part of the same restriction. {cmd:markout}
can be used after {cmd:mark} or {cmd:marksample} when there are variables
other than the varlist, and when observations that contain missing values of
those variables are also to be excluded.
{pstd}
{cmd:markin} is for use after {cmd:marksample}, {cmd:mark}, and {cmd:markout},
and should be used only with extreme caution. Its use is never necessary, but,
in the case where it is known that the specified {cmd:if} {it:exp} will select
a small subset of the observations (small being, for instance, 6 out of
750,000), using {cmd:markin} can result in code that executes more quickly.
{cmd:markin} creates local macro {cmd:`}{it:local_macro_name}{cmd:'} (or
{cmd:`in'} if option {cmd:name()} is not specified) containing the smallest
{cmd:in} {it:range} that contains the {cmd:if} {it:exp}.
{pstd}
{cmd:svymarkout} resets the values of {it:markvar} to contain 0 wherever any
of the survey-characteristic variables (previously set by {cmd:svyset})
contain missing values. See {helpb svymarkout} for additional information.
{title:Options}
{phang}{cmd:novarlist} is for use with {cmd:marksample}. It specifies that missing values among variables in {it:varlist} not cause the marker variable to be set to 0. Specify {cmd:novarlist} if you previously specified
{cmd:syntax newvarlist} ...
or
{cmd:syntax newvarname} ...
{pmore}
In addition, you should specify {cmd:novarlist} in instances where missing
values are not to cause observations to be excluded (perhaps you are analyzing
the pattern of missing values).
{phang}{cmd:strok} is used with {cmd:marksample} or {cmd:markout}. Specify
this option if string variables in {it:varlist} are to be allowed.
See {hi:[P] mark}.
{phang}{cmd:zeroweight} is for use with {cmd:marksample} or {cmd:mark} and
indicates that zero weights are not to be excluded because the weight is
zero.
{phang}{cmd:noby} is used rarely and only in {cmd:byable(recall)} programs.
It specifies that, in identifying the sample, the restriction to the by-group
be ignored. {cmd:mark} and {cmd:marksample} are to create the marker variable
as it would had the user not specified the {cmd:by ...:} prefix. If the user
did not specify the {cmd:by} prefix, specifying {cmd:noby} has no effect.
{cmd:noby} provides a way for {cmd:byable(recall)} programs to identify the
overall sample. For instance, if the program needed to calculate the
percentage of observations in the by-group, the program would need to know
both the sample to be used on this call and the overall sample. The program
might be coded as
{cmd:program define} {it:...}{cmd:, byable(recall)}
{it:...}
{cmd:marksample touse}
{cmd:marksample alluse, noby}
{it:...}
{cmd:qui count if `touse'}
{cmd:local curN = r(N)}
{cmd:qui count if `alluse'}
{cmd:local totN = r(N)}
{cmd:local frac = `curN'/`totN'}
{it:...}
{cmd:end}
{phang}
{cmd:name()} is for use with {cmd:markin} only. It specifies the name of the
macro to be created. If {cmd:name()} is not specified, the name {cmd:in} is
used.
{title:Example}
{cmd:program define} {it:...}
{cmd:syntax} {it:...}
{cmd:marksample touse}
{it:...}
{it:...} {cmd:if `touse'} {it:...}
{it:...}
{cmd:end}
{title:Also see}
{psee}
Manual: {bf:[P] mark}
{psee}
Online: {help byprog}, {helpb svymarkout}, {helpb syntax}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -