## Stata 15 help for ameans

```
[R] ameans -- Arithmetic, geometric, and harmonic means

Syntax

ameans [varlist] [if] [in] [weight] [, options]

options           Description
-------------------------------------------------------------------------
Main
only            add # only to variables with nonpositive values
level(#)        set confidence level; default is level(95)
-------------------------------------------------------------------------
by is allowed; see [D] by.
aweights and fweights are allowed; see weight.

Statistics > Summaries, tables, and tests > Summary and descriptive
statistics > Arith./geometric/harmonic means

Description

ameans computes the arithmetic, geometric, and harmonic means, with their
corresponding confidence intervals, for each variable in varlist or for
all the variables in the data if varlist is not specified.  gmeans and
hmeans are synonyms for ameans.

Options

+------+
----+ Main +-------------------------------------------------------------

add(#) adds the value # to each variable in varlist before computing the
means and confidence intervals.  This option is useful when analyzing
variables with nonpositive values.

only modifies the action of the add(#) option so that it adds # only to
variables with at least one nonpositive value.

level(#) specifies the confidence level, as a percentage, for confidence
intervals. The default is level(95) or as set by set level.

Examples

Setup
. webuse systolic

Compute arithmetic, geometric, and harmonic means
. ameans systolic

Same as above, but add 7 to systolic before computing means

Video example

Descriptive statistics in Stata

Stored results

ameans stores the following in r():

Scalars
r(N)           number of nonmissing observations; used for arithmetic
mean
r(N_pos)       number of nonmissing positive observations; used for
geometric and harmonic means
r(mean)        arithmetic mean
r(lb)          lower bound of confidence interval for arithmetic mean
r(ub)          upper bound of confidence interval for arithmetic mean
r(Var)         variance of untransformed data
r(mean_g)      geometric mean
r(lb_g)        lower bound of confidence interval for geometric mean
r(ub_g)        upper bound of confidence interval for geometric mean
r(Var_g)       variance of ln x_i
r(mean_h)      harmonic mean
r(lb_h)        lower bound of confidence interval for harmonic mean
r(ub_h)        upper bound of confidence interval for harmonic mean
r(Var_h)       variance of 1/x_i
r(level)       confidence level of confidence interval

```