__Title__

**[R] margins, saving()** -- Save margins results to a dataset

__Syntax__

**margins** [*marginlist*] [*if*] [*in*] [*weight*] [**,** __sav__**ing(***filename***, ...)**
*response_options* *options*]

__Description__

**margins,** **saving()** saves a dataset containing the statistics reported in
the output.

__Remarks__

Each observation in the **margins,** **saving()** dataset corresponds with a row
in the output table.

The following variables are always present:

**_deriv** identifies the variable that the margin values were
differentiated with respect to. The values in **_deriv** are labeled
with the independent variables specified in the **dydx()** options;
otherwise, **_deriv** contains all missing values. For factor
variables, the factor level is contained in the label.

**_term** identifies the factor variables participating in the *marginlist*
term associated with the estimated margin value. The values in
**_term** are labeled with a list of the names of the factor
variables present in the terms specified in *marginlist*; the grand
margin is labeled "_cons".

**_predict** identifies the **predict()** option associated with the
estimated margin value. The values in **_predict** are labeled with
the **predict()** option. **_predict** contains missing values when the
**expression()** option is specified.

The **_dta[k_predict]** characteristic identifies how many **predict()**
options were specified or implied. This characteristic is empty
when the **expression()** option is specified with an expression that
contains more than just a reference to an equivalent **predict()**
option.

**_margin** contains the estimated margin values.

**_se** contains the estimated standard errors of the estimated margin
values.

**_statistic** contains the value of the *z* (or *t*) statistic for testing
the margin values against zero.

**_pvalue** contains the observed significance level for a two-sided test
of the marginal values against zero.

**_ci_lb** and **_ci_ub** contain the confidence interval limits for the
margin values.

A variable with the **_m** prefix is present for each unique factor variable
specified in *marginlist*.

**_m***#* contains the levels of the *#*th unique factor variable in
*marginlist*, identifying the level corresponding with the
estimated margin value. **_m***#* is missing if the associated factor
variable is not in the list of factor variables corresponding
with the term for a given estimated margin value.

The **_m***#***[varname]** characteristic identifies the factor variable
that **_m***#* corresponds to.

The **_dta[margin_vars]** characteristic contains the names of the
factor variables associated with the **_m***#* variables.

A variable with the **_at** prefix is present for each unique independent
variable in the model when one or more independent variables is fixed
because of options **atmeans**, **asbalanced**, or **at()**.

**_at***#* contains the value at which the *#*th independent variable was
fixed. For factor variables, **_at***#* contains the **.b** missing value
if the factor variable was treated as balanced. **_at***#* contains
the **.o** missing value if the variable was left as observed.

The **_at***#***[varname]** characteristic identifies the independent
variable that **_at***#* corresponds to. The **_at***#***[stats]**
characteristic identifies the statistic at which the variable was
set; there is one statistic for each **at()** option. In addition to
the statistics documented with the **at()** option, the following
identifiers are used when one or multiple values are specified in
the **at()** option: **value** and **values**.

The **_dta[at_vars]** characteristic contains the names of the
independent variables associated with the **_at***#* variables.

The **_dta[k_at]** characteristic identifies how many **at()** options
were specified/implied. The **_dta[atopt***#***]** characteristic
identifies the specification of the *#*th **at()** option. The
**_dta[atstats***#***]** characteristic identifies the specification
attached to the variables in the *#*th **at()** option.

There will also be an **_at** variable that identifies groups of margin
values associated with patterns in the **_at***#* variables and an
**_atopt** variable that identifies groups of margin values
associated with each **at()** option.

A variable with the **_by** prefix is present for each variable specified in
the **over()** and **within()** options.

**_by***#* identifies the group level of the *#*th grouping variable
associated with the estimated margin value.

The **_by***#***[varname]** characteristic identifies the group variable
that **_by***#* corresponds to.

The **_dta[by_vars]** characteristic contains the names of the group
variables associated with the **_by***#* variables. The **_dta[over]**
characteristic identifies the **over()** variables, and the
**_dta[within]** characteristic identifies the **within()** variables.