help mata range_mv()

Title

range_mv() -- Real vector over range

Syntax

real colvector
range_mv(real scalar a,
real scalar b)

real colvector
range_mv(real scalar a,
real scalar b,
real scalar d)

real scalar
_range_mv(R,
real scalar a,
real scalar b)

real scalar
_range_mv(R,
real scalar a,
real scalar b,
real scalar d)

where either none or both a and b may be missing value codes
., .a, .b, ..., .z.

The type of R is irrelevant because it is replaced with a real column
vector.

Description

range_mv() is similar to range() (but restricted
to real numbers) and returns a column vector from a to <=b
(b>a) or >=b (b<a) in steps of
abs(d). The function returns the same result as Stata's
numlist command. The sign of d is irrelevant; if not
specified, d defaults to d=1.

_range_mv() does the same as above but places the resulting column
vector into R and returns the error code.

The ordering of missing value codes is as usual

. < .a < .b < ... < .z

and, additionally, the distance between successive missing values is set
to 1. Thus, range_mv(., .c) returns (. \ .a \ .b \ .c) and
range_mv(., .c, 3) returns (. \ .c). When a and b are
missing, d is interpreted as trunc(d).

Conformability

range_mv(a, b, d)
a: 1 x 1
b: 1 x 1
d: 1 x 1
result: r x 1

_range_mv(R, a, b, d)
input:
a: 1 x 1
b: 1 x 1
d: 1 x 1
output:
R: r x 1
result: 1 x 1

Diagnostics

range_mv() aborts with error if d contains missing
or 0, or if only one of a or b contain missing.

_range_mv() places in R, J(0, 1, .) and returns
!=0 if d contains missing or 0, or if only one of a or
b contain missing.

Source code

Distributed with the elabel package.

Author

Daniel Klein

University of Kassel

klein.daniel.81@gmail.com

Also see

Online: mata, range()