📄 statsby.hlp
字号:
{smcl}
{* 29mar2005}{...}
{cmd:help statsby}{right:dialog: {bf:{dialog statsby}}}
{hline}
{title:Title}
{p2colset 5 20 22 2}{...}
{p2col :{hi:[D] statsby} {hline 2}}Collect statistics for a command across a by list{p_end}
{p2colreset}{...}
{title:Syntax}
{p 8 16 2}
{cmd:statsby}
[{it:{help exp_list}}]
[{cmd:,} {it:options} ]
{cmd::}
{it:command}
{synoptset 25 tabbed}{...}
{synopthdr}
{synoptline}
{syntab :Main}
{p2coldent :* {cmd:by(}{help varlist:{it:varlist}} [{cmd:,} {cmdab:mis:sing}]{cmd:)}}equivalent to interactive use of {cmd:by} {it:varlist}{cmd::}{p_end}
{syntab :Options}
{synopt :{opt clear}}replace data in memory with results{p_end}
{synopt :{help prefix_saving_option:{bf:saving(}{it:filename}{bf:, ...)}}}save
results to {it:filename}; save statistics in double precision; save
results to {it:filename} every {it:#} replications{p_end}
{synopt :{opt t:otal}}include results from entire dataset{p_end}
{synopt :{opt s:ubsets}}include all combinations of subsets of groups{p_end}
{synopt :{opt force}}do not check for {cmd:svy} commands; seldom used{p_end}
{syntab :Reporting}
{synopt :{opt nodots}}suppress the replication dots{p_end}
{synopt :{opt noi:sily}}display any output from {it:command}{p_end}
{synopt :{opt tr:ace}}trace the {it:command}{p_end}
{synopt :{opt nol:egend}}suppress the table legend{p_end}
{synopt :{opt v:erbose}}display the full table legend{p_end}
{synoptline}
{p2colreset}{...}
{p 4 6 2}* {opt by()} is required on the dialog box because {cmd:statsby} is
only useful to the interactive user when using {opt by()}.{p_end}
{p 4 6 2}All weight types supported by {it:command} are allowed; see {help weight}.
{title:Description}
{pstd}
{cmd:statsby} collects statistics from {it:command} across a {cmd:by()}
list. Typing
{phang2}
{cmd:. statsby} {it:exp_list} {cmd:,} {opt by(varname)} {cmd::} {it:command}
{pstd}
executes {it:command} for each group identified by {it:varname}, building a
dataset of the associated values from the expressions in {it:exp_list}. The
resulting dataset replaces the current dataset, unless the {cmd:saving()}
option is supplied.
{pstd}
{it:command} defines the statistical command to be executed.
Most Stata commands and user-written programs can be used with {cmd:statsby},
as long as they follow {help language:standard Stata syntax}
and allow the {it:{help if}} qualifier.
The {cmd:by} prefix cannot be part of {it:command}.
{pstd}
{it:exp_list} specifies the statistics to be collected from the execution of
{it:command}. The expressions in {it:exp_list} follow the grammar given in
{it:{help exp_list}}.
If no expressions are given, {it:exp_list} assumes a default depending upon
whether {it:command} changes results in {cmd:e()} and {cmd:r()}. If
{it:command} changes results in {cmd:e()}, the default is {cmd:_b}. If
{it:command} changes results in {cmd:r()} (but not {cmd:e()}), the default is
all the scalars posted to {cmd:r()}. It is an error not to specify an
expression in {it:exp_list} otherwise.
{title:Options}
{dlgtab:Main}
{phang}
{cmd:by(}{help varlist:{it:varlist}} [{cmd:, missing}]{cmd:)} specifies a list
of existing variables that would normally appear in the
{cmd:by} {it:varlist}{cmd::} section of the command if you were to issue the
command interactively. By default, {cmd:statsby} ignores groups in which one
or more of the {cmd:by()} variables is missing. Alternatively, {opt missing}
causes missing values to be treated like any other values in the {cmd:by()}
groups, and results from the entire dataset are included with use of the
{opt subsets} option. If {cmd:by()} is not specified, {it:command} will be
run on the entire dataset.
{dlgtab:Options}
{phang}
{opt clear} specifies that it is okay to replace the data in memory,
even though the current data have not been saved to disk.
INCLUDE help prefix_saving_option
{pmore}
See help {it:{help prefix_saving_option}}, for details about {it:suboptions}.
{phang}
{opt total} specifies that {it:command} be run on the entire dataset,
in addition to the groups specified in the {opt by()} option.
{phang}
{opt subsets} specifies that {it:command} be run for each group
defined by any combination of the variables in the {opt by()} option.
{phang}
{opt force} suppresses the restriction that {it:command} not be a {cmd:svy}
command. {cmd:statsby} does not perform subpopulation estimation for survey
data, so it should not be used with {cmd:svy}. {cmd:statsby}
reports an error when it encounters {cmd:svy} in {it:command} if the
{cmd:force} option is not specified. This option is seldom used so use it
only if you know what you are doing!
{dlgtab:Reporting}
{phang}
{opt nodots} suppresses display of the replication dots. By default, a single
dot character is printed for each {cmd:by()} group; however, a single red `x'
is printed if {it:command} returns with an error or one of the values in
{it:exp_list} is missing.
{phang}
{opt noisily} causes the output of {it:command} to be displayed for each
{opt by()} group. This option implies the {opt nodots} option.
{phang}
{opt trace} causes a trace of the execution of {it:command} to be displayed.
This option implies the {opt noisily} option.
{phang}
{opt nolegend} suppresses the displaying of the table legend, which identifies
the rows of the table with the expressions they represent.
{phang}
{opt verbose} requests that the full table legend be displayed. By default,
coefficients and standard errors are not displayed.
{title:Example: Collecting coefficients}
{phang}
{cmd:. statsby , by(for): regress price weight length mpg}{p_end}
{phang}
{cmd:. statsby _b , by(rep): heckman price mpg, sel(for=trunk)}{p_end}
{phang}
{cmd:. statsby [price]_b, by(rep): heckman price mpg, sel(for=trunk)}
{title:Example: Collecting standard errors}
{phang}
{cmd:. statsby _se, by(for): regress price weight mpg}{p_end}
{phang}
{cmd:. statsby _se, by(rep): heckman price mpg, sel(for=trunk)}{p_end}
{phang}
{cmd:. statsby [price]_se, by(rep): heckman price mpg, sel(for=trunk)}
{title:Example: Collecting saved results}
{phang}
{cmd:. statsby mean=r(mean) median=r(p50), by(for): sum price, detail}{p_end}
{phang}
{cmd:. statsby ratio = (r(mean)/r(p50)), by(for): sum price, detail}
{title:Also see}
{psee}
Manual: {bf:[D] statsby}
{psee}
Online:
{helpb bootstrap},
{helpb collapse},
{helpb jackknife},
{helpb permute},
{helpb postfile}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -