Command Reference : Function Reference : Function Reference: B
  
 
@before
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.