Function Reference: B
@before Indicators for whether observation precedes a date.
@beta Beta integral (Euler integral of the second kind).
@betaincder Derivative of the incomplete beta integral.
@betalog Natural logarithm of the beta integral.
@between Dummy variable for value within range of values.
@binomlog Natural logarithm of the binomial coefficient.
@bridge Copy of a series using the current or preceding non-missing value.
Indicator for whether an observation precedes a given date.
Syntax: @before(d)
d: string, alpha
Return: series
Returns a series containing indicators for whether each observation precedes the beginning of the specified date d.
• For dates d that are of equal or lower frequency than the observation, the results are (0, 1) indicators of whether the observation precedes the beginning of d.
• For dates d that are of higher frequency than the observation, the (0, n) results reflect the fraction of the observation before the beginning of d.
Examples
Suppose that we have a quarterly workfile with data from 2020q1 to 2022q4 that we create with the command:
workfile q 2020 2022
The command
series before_y = @before("2022")
uses a lower-frequency “yearly” date to creates the series BEFORE_Y containing the value 1 from 2020q1 through 2021q4, and the value 0 elsewhere.
Using a “quarterly” date,
series before_q = @before("2022q3")
creates the series BEFORE_Q containing the value 1 from 2020q1 through 2022q2 and the value 0 elsewhere.
The command using a higher frequency “monthly” date
series before_m = @before("2022m5")
generates the series BEFORE_M containing the value 1 from 2020q1 through 2022q1, a fractional value for 2022q2 which contains 2022m5, and the value 0 beginning in 2022q3 through the end of the data.
For the fractional 2022q2 value, there are 30 days in 2022-April that precede the beginning of the “2022m5” date. There are 91 days in the full quarter, so the fractional before value for 2022q2 is 30/91 = 0.32967.
Cross-references
See also
@before and
@during.
Beta integral (Euler integral of the second kind).
Syntax: @beta(a, b)
a: number
b number
Return: number
Compute the value of the beta integral for elements of a and b:
for

.
Examples
= @beta(1,5)
returns 0.2 (same as 1/5).
Cross-references
Incomplete beta integral.
Syntax: @betainc(x, a, b)
x: number
a: number
b number
Return: number
Compute the value of the incomplete beta integral for elements of x, a and b:
for

and

.
Examples
= @betainc(0.5,3,1)
returns 0.125 (same as 0.5 raised to the power of 3).
Cross-references
Derivative of the incomplete beta integral.
Syntax: @betaincder(x, a, b, c)
x: number
a: number
b number
c integer
Return: number
Given the incomplete beta integral for elements of x, a and b:
for

and

, compute the derivative given by
c where
c is an integer from 1 to 9 indicating the desired derivative,
If
c is not an integer, the integer floor

will be used.
Examples
= @betaincder(0.5,2,2,1)
returns 1.5.
Cross-references
Inverse of the incomplete beta integral.
Syntax: @betaincinv(x, a, b, p)
p: number
a: number
b number
Return: number
Returns the x satisfying the incomplete beta integral for elements of p, a and b:
for

and

.
Examples
= @betaincinv(0.5,2,2)
returns 0.5.
Cross-references
Natural logarithm of the beta integral.
Syntax: @betalog(a, b)
a: number
b number
Return: number
Compute the value of the beta integral for elements of a and b:
for

.
Examples
= @betalog(2,1)
returns -0.69314....
Cross-references
Dummy variable for observation value within range of values.
Syntax: @between(x, v1, v2)
x: number or string
v1: number or string
v2: number or string
Return: number
where v1 and v2 correspond to the low and high values of the range.
Returns a dummy variable series equal to 1 for observations where x is greater than or equal to v1 and less than or equal to v2, and 0 otherwise.
Examples
series d1 = @between(x, 10, 100)
creates a dummy variable that takes the value 1 where the value of X is in the range defined by the values 10 and 100.
series d2 = @between(x, lowvals, highvals)
creates a dummy variable that takes the value 1 where the value of X is in the range defined by the series LOWVALS and HIGHVALS.
Cross-references
See also
@inlist, and
@between.
Binomial coefficient.
Syntax: @binom(n, x)
a: number
b number
Return: integer
Compute the value of the beta integral for elements of a and b:
for integers

and

. If
n or
x are not integers, the integer floors

and

will be used.
Examples
= @binom(4,2)
returns 6.
Cross-references
Natural logarithm of the binomial coefficient.
Syntax: @binomlog(n, x)
n: integer
x: integer
Return: number
Compute the value of the beta integral for elements of a and b:
for integers

and

.
If
n or
x are not integers, the integer floors

and

will be used.
Examples
= @binomlog(2,1)
returns 0.69314....
Cross-references
Bounded values.
Syntax: @bounds(x, y, z)
x: number
y: number
z: number
Return: number
Returns

if

, or the boundary values

if

or

if
.Examples
= @bounds(x, 0, 1)
returns the value of x if x is in the unit interval, 0 if x is negative, and 1 if x is greater than 1.
Copy of a series using current or preceding non-missing value.
Syntax: @bridge(x)
x: series
Return: series
Returns a copy of series x with NAs replaced by the nearest preceding non-NA value.
This function is panel aware.
Examples
series x = @recode(@rnd < 0.5, na, @nrnd)
show @bridge(x)
The first line create a series x of NAs and IID standard normal variates. The second line shows x with @bridge applied. Note that NAs that appear at the beginning of the series do not get replaced.
Cross-references