Dated Workfile Information
Basic Date Functions
EViews offers a set of functions that provide information about the dates in your dated workfiles. The first two functions return the start and end date of the period of time (interval) associated with each observation in the workfile:
• @date: returns the start date of the period of time of each observation of the workfile.
• @enddate: returns the end date of the period of time associated with each observation of the workfile.
Each date is returned in a number using standard EViews date representation (fractional days since 1st Jan A.D. 1; see
“Dates”).
A period is considered to end during the last millisecond contained within the period. In a regular frequency workfile, each period will end immediately before the start of the next period. In an irregular workfile there may be gaps between the end of one period and the start of the following period due to observations that were omitted in the workfile.
The @date and @enddate functions may be combined with EViews date manipulation functions to provide a wide variety of calendar information about a dated workfile.
For example, if we had a monthly workfile containing sales data for a product, we might expect the total sales that occurred in a given month to be related to the number of business days (Mondays to Fridays) that occurred within the month. We could create a new series in the workfile containing the number of business days in each month by using:
series busdays = @datediff(@date(+1), @date, "B")
If the workfile contained irregular data, we would need to use a more complicated expression since in this case we cannot assume that the start of the next period occurs immediately after the end of the current period. For a monthly irregular file, we could use:
series busdays = @datediff(@dateadd(@date, 1, "M"), @date, "B")
Similarly, when working with a workfile containing daily share price data, we might be interested in whether price volatility is different in the days surrounding a holiday for which the market is closed. We may use the first formula given above to determine the number of business days between adjacent observations in the workfile, then use this result to create two dummy variables that indicate whether each observation is before or after a holiday day.
series before_holiday = (busdays > 1)
series after_holiday = (busdays(-1) > 1)
We could then use these dummy variables as exogenous regressors in the variance equation of a GARCH estimation to estimate the impact of holidays on price volatility.
In many cases, you may wish to transform the date numbers returned by @date so that the information is contained in an alternate format. EViews provides workfile functions that bundle common translations of date numbers to usable information. These functions include:
• @year: returns the four digit year in which each observation begins. It is equivalent to “@datepart(@date, "YYYY")”.
• @quarter: returns the quarter of the year in which each observation begins. It is equivalent to “@datepart(@date, "Q")”.
• @month: returns the month of the year in which each observation begins. It is equivalent to “@datepart(@date, "MM")”.
• @day: returns the day of the month in which each observation begins. It is equivalent to “@datepart(@date, "DD")”.
• @weekday: returns the day of the week in which each observation begins, where Monday is given the number 1 and Sunday is given the number 7. It is equivalent to “@datepart(@date, "W")”.
• @hour: returns the hour associated with each observation as an integer. For example, 9:30AM returns 9, and 5:15PM returns 17.
• @minute: returns the minute associated with each observation as an integer. For example, 9:30PM returns 30.
• @second: returns the second associated with each observation as an integer.
• @hourf: returns the time associated with observation as a floating point hour. For example, 9:30AM returns 9.5, and 5:15PM returns 17.25.
• @strdate(
fmt): returns the set of observation dates as strings, using the date format string
fmt. See
“Date Formats”for a discussion of date format strings.
• @seas(season_number): returns dummy variables based on the period within the current year in which each observation occurs, where the year is divided up according to the workfile frequency. For example, in a quarterly file, “@seas(1)”, “@seas(2)”, “@seas(3)”, and “@seas(4)” correspond to the set of dummy variables for the four quarters of the year. these expressions are equivalent (in the quarterly workfile) to “@quarter=1”, “@quarter=2”, “@quarter=3”, and “@quarter=4”, respectively.
• @isperiod(arg): returns dummy variables for whether each observation is in the specified period, where arg is a double quoted date or period number. Note that in dated workfiles, arg is rounded down to the workfile frequency prior to computation.
Additional information on working with dates is provided in
“Dates”.
Trend Functions
One common task in time series analysis is the creation of variables that represent time trends. EViews provides two distinct functions for this purpose:
• @trend(["base_date"]): returns a time trend that increases by one for each observation of the workfile. The optional base_date may be provided to indicate the starting date for the trend.
• @trendbr(["base_date"]): returns a time trend (with optional break point) that increases by one for each observation of the workfile. The optional base_date may be provided to indicate the starting date for the trend. Trend values before base_date will be zero.
• @trendc(["base_date"]): returns a calendar time trend that increases based on the number of calendar periods between successive observations. The optional base_date may be provided to indicate the starting date for the trend.
The functions @trend and @trendc are used to represent two different types of time trends that differ in some circumstances:
• In a regular frequency workfile, @trend and @trendc both return a simple trend that increases by one for each observation of the workfile.
• In an irregular workfile, @trend provides an observation-based trend as before, but @trendc now returns a calendar trend that increases based on the number of calendar periods between adjacent observations. For example, in a daily irregular file where a Thursday has been omitted because it was a holiday, the @trendc value would increase by two between the Wednesday before and the Friday after the holiday, while the @trend will increase by only one.
Both @trend and @trendc functions may be used with an argument consisting of a string containing the date at which the trend has the value of zero. If this argument is omitted, the first observation in the workfile will be given the value of zero.
The choice of which type of time trend is appropriate in a particular context should be based on what role the time trend is playing in the analysis. When used in estimation, a time trend is usually used to represent some sort of omitted variable. If the omitted variable is something that continues to increase independently of whether the workfile data is observed or not, then the appropriate trend would be the calendar trend. If the omitted variable is something that increases only during periods when the workfile data is observed, then the appropriate trend would be the observation trend.
An example of the former sort of variable would be where the trend is used to represent population growth, which continues to increase whether, for example, financial markets are open on a particular day or not. An example of the second sort of variable might be some type of learning effect, where learning only occurs when the activity is actually undertaken.
Note that while these two trends are provided as built in functions, other types of trends may also be generated based on the calendar data of the workfile. For example, in a file containing monthly sales data, a trend based on either the number of days in the month or the number of business days in the month might be more appropriate than a trend that increments by one for each observation.
These sorts of trends can be readily generated using @date and the @datediff functions. For example, to generate a trend based on the number of days elapsed between the start date of the current observation and the base date of 1st Jan 2000, we can use:
series daytrend = @datediff(@date, @dateval("1/1/2000"), "d")
When used in a monthly file, this series would provide a trend that adjusts for the fact that some months contain more days than others.
Note that trends in panel structured workfiles follow special rules. See
“Panel Trend Functions” for details.
Event Functions
These functions return information about each observation’s relationship with a specified date, or date range:
Basic Functions
• @daycount([“weekday_range”]): Returns the number of calendar days within each observation of the workfile. The optional weekday_range argument lets you specify certain days of the week to count.
If only one weekday is provided, @daycount returns the number of times that particular weekday occurs within the observation. If two weekdays are provided, @daycount returns the number of times that any weekday between (and including) the two weekdays occurs within the observation.
• @before("date"): returns a dummy variable with a value of 1 for each observation prior to date, and zero for every other observation. If an observation is partially before date (for example if you have a monthly workfile and specify a day as date), the fraction of the observation before date is returned.
• @after("date"): returns a dummy variable with a value of 1 for each observation after, and including, date, and zero for every other observation. If an observation is partially before date (for example if you have a monthly workfile and specify a day as date), the fraction of the observation after and including date is returned.
• @during("date1 date2"): returns a dummy variable with a value of 1 for each observation between date1 and date2 (inclusive), and zero for every other observation. If an observation partially covers the specified dates (for example if you have a monthly workfile and specify a pair of days in the same month), the fraction is returned.
Event Function
The event function returns a variable containing the proportion of a one-off event covered by each observation. The event can be specified by a single date, or by a pair of dates to denote a date range.
Syntax: @event("d1 [d2]"[, b])
d1: string
b: (optional) string
Return: series
where d1 and d2 are dates defining the one-off event specification and b is a basis specification.
Returns the proportion or identifier of a one-off event covered by the observation, for each observation in the workfile. If the workfile has a regular frequency and spans the entire event, the returned series will sum to one over all observations. If the workfile is irregular or does not span the entire event, the series may sum to less than one due to the observations that have been omitted.
The optional basis parameter may be used to specify that only certain days of the week or times of the day should be included as part of the holiday. This parameter has the format
"start_weekday-end_weekday[, start_time-end_time]"
e.g. “mon-thu” or “mon-sun,10am-4pm”.
@event is similar to the holiday functions below, but handles only a single non-repeating date or date range and only the basis option.
Holiday Functions
The @holiday and @holidayset functions allow you to analyze and account for different behavior on holiday days, around the world. These functions may be used to create series that indicate the proportion of an annual event covered by each observation.
The @holiday function returns the proportion or identifier of an annual event covered by the observation, for each observation in the workfile.
The basic syntax for the holiday function is
Syntax: @holiday(h[, b][, flag...])
h: string
b: string
flag: (optional) string
Return: series
where h is the holiday event specification, b is a basis specification, and flag is a calculation scaling flag.
@holiday is similar to @holidayset, but allows for the specification of holidays using a range pair of dates, while disallowing multiple holiday event specifications.
The @holidayset function returns the proportion or identifier of multiple annual events covered by the observation, for each observation in the workfile.
The basic syntax for the holiday set function is
Syntax: @holidayset(h[, b][, flag...])
h: string
b: string
flag: (optional) string
Return: series
where h is one or more holiday event specifications, b is a basis specification, and flag is a calculation scaling flag.
Event Specification
The h specification identifies holiday events using date specifications of the form:
"base[~|!][(offset)][[weights]]"
where the base component consists of a single date, a pair of dates (forming a range), or a single or a named group of holidays:
• A single date consists of either a day-of-the-month specification (
e.g., “Dec25”), an
n‑th-weekday-of-the-month specification (
e.g., “Nov4Thu” for the fourth Thursday in November or “May-1Mon” for the l Monday in May), or a named holiday (
“Named Holidays”).
• Multiple dates may be specified using a date range (
e.g., “Dec25 Jan05”, “Nov4Thu May-1Mon”), or a named group of holidays (
“Named Groups”).
The remainder of the specification consists of optional settings. The base component specification may be followed by any of the following options:
For a base consisting of a range pair of dates, optional settings may be provided for both the start and end dates.
For a base consisting of a named group, the optional settings will be applied to each of the individual members of the group.
Named Holidays
EViews supports named holidays for common holidays in the G8 countries, including the following ecclesiastical holidays: “epiphany”, “easterfriday”, “goodfriday”, “easter”, “eastermonday”, “ascension”, “pentecost”, “whitmonday”, “assumption”, “allsaints”, “immaculate”, “christmas”, “saintstephen.
Also available are New Years Day (“nyd”, “newyear”, and “newyears”), Lunar New Year (“cny”, “lny”, and “lunarnewyear”), International Women’s Day (“women” and “womens”), and International Men’s Day (“men” and “mens”).
Named holidays primarily associated with a specific country are suffixed with a locale code following ISO 3166-1 alpha-2, i.e., the Internet country codes for top-level domains such as “.ca” and “.de”. These named holidays are:
• Canada – “victoria.ca”, “canada”, “civic.ca”, “labour.ca”, “thanksgiving.ca” (also“thanks.ca”), “remembrance.ca”, “boxing.ca”
• France – “labour.fr”, “victory.fr”, “bastille.fr”, “armistice.fr”
• Germany – “labour.de”, “unity.de”
• Italy – “liberation.it”, “labour.it”, “republic.it”
• Russia – “christmas.ru”, “defender.ru”, “springlabour.ru”, “victory.ru”, “russia”, “unity.ru”
• United Kingdom – “mayday.uk”, “springbank.uk”, “summerbank.uk”, “boxing.uk”
• United States of America – “mlk.us”, “presidents.us”, “memorial.us”, “independence.us”, “labor.us”, “columbus.us”, “veterans.us”, “thanksgiving” (also “thanks”)
Note that the named holidays “canada”, “russia”, and “thanksgiving” do not include a suffix, either to avoid redundancy or maintain compatibility with earlier versions of EViews. Also note that “christmas.ru” is included to reflect the Russian Orthodox Church’s use of the Julian calendar.
In general, a suffix may be safely added to any named holiday that does not already include one,
e.g. “christmas.us” or “nyd.it”. Unless noted above, such combinations do not alter the nominal date of the holiday but may produce different results when combined with a weekend modifier (
“Modifiers”).
Named Groups
Named groups are preset collections of holidays. EViews currently supports a single named group, “bank”, for each of the supported locales, i.e., “bank.ca”, “bank.fr”, “bank.de”, etc., allowing easy access to the common bank holidays.
The membership of these groups are:
• Canada, “bank.ca” – “nyd goodfriday victoria canada civic labour thanksgiving remembrance christmas boxing”
• France, “bank.fr” –“ nyd eastermonday labour victory ascension whitmonday bastille assumption allsaints armistice christmas”
• Germany, “bank.de” – “nyd goodfriday eastermonday labour ascension whitmonday unity christmas saintstephen”
• Italy, “bank.it” – “nyd epiphany easter eastermonday liberation labour republic assumption allsaints immaculate christmas saintstephen”
• Russia, “bank.ru” – “nyd christmas defender womens springlabour victory russia unity”
• United Kingdom, “bank.uk” – “nyd goodfriday eastermonday mayday springbank summerbank christmas boxing”
• United States of America, “bank.us” – “nyd mlk presidents memorial independence labor columbus veterans thanksgiving christmas”
All named group members have an implied suffix matching the group’s suffix. When using a named group, the sum of proportion values within a year will equal the number of group members (ignoring sample effects).
Modifiers
A weekend modifier character “~” or “!” indicates special handling of dates that fall on weekends.
• If “~” is used, then the date will be adjusted to the nearest weekday. A date landing on a Saturday is adjusted to the preceding Friday, and a date landing on a Sunday is adjusted to the following Monday.
• If “!” is used with a named holiday, then a more sophisticated set of rules is used to determine when the holiday will be observed, reflecting public holiday and bank holiday conventions.
In some locales, holidays are observed according to the simple rule encapsulated by the “~” modifier and thus the two modifiers will behave identically. For example, suppose we are evaluating “christmas.us!” for the year 2021. That date lands on a Saturday and the holiday will be observed on the preceding Friday, Dec. 24. However, if evaluating “christmas.uk!” for the same year, weekend holidays are observed on the nearest following weekday in this locale, thus the holiday will be observed on Monday, Dec. 27. Similarly, “boxing.uk!” will be observed on Tuesday, Dec. 28.
Offsets
A date followed by a parenthetical offset will be adjusted by the given number of days. For example, “christmas(-1)” could be used to specify Christmas Eve. If a weekend modifier is also present, e.g. “christmas~(-1)”, the offset is applied after any adjustment made by the modifier.
Basis
The optional basis parameter may be used to specify that only certain days of the week or times of the day should be included as part of the holiday. This parameter has the format
"start_weekday-end_weekday[, start_time-end_time]"
e.g. “mon-thu” or “mon-sun,10am-4pm”.
Weights
A date followed by a bracketed list of weights is considered to occur over multiple days. The specified weights determine the relative proportion of the holiday occurring on each day, with the sum of proportions across all days within a year equaling one. The list must contain an odd number of terms, with the middle term corresponding to the nominal date of the holiday (after adjustment from any weekend modifier or offset).
For example, evaluating “christmas” for a daily workfile would return the value 1 for the observation on Dec. 25 and the value 0 for all other observations in that year. Evaluating “christmas[1,2,1]” would return the value 0.25 for the observation on Dec. 24, the value 0.5 for Dec. 25, and the value 0.25 for Dec. 26, returning the value 0 for all other observations.
Several named weight patterns are available as alternatives to explicit weight lists:
• “rampup(n)” – An increasing integer sequence of length
ending on the date. For example, “[rampup(3)]” is equivalent to “[1,2,3,0,0]”.
• “rampdown(n)” – A decreasing integer sequence of length
beginning on the date. For example, “[rampdown(3)]” is equivalent to “[0,0,3,2,1]”.
• “ramp(n)” –An increasing and then decreasing integer sequence centered on the date. For example, “[ramp(3)]” is equivalent to “[1,2,3,2,1]”.
Note that weights may not be included when a pair of dates is used to specify a range in @holiday.
Flag
The optional flag parameter supports two options, “binary” and “denorm”.
• If “binary” is specified, any non-zero value that would be returned by @holiday is replaced by one, thus forcing the function to return only zeros and ones. This flag is equivalent to the expression “@holiday(...)>0”.
• If “denorm” is specified, then the default normalization steps for weighted dates (dividing by the sum of weights) and sets or groups of holidays (dividing by the number of distinct holidays) are not performed.
For example, @holiday("christmas[1,2,1]") returns values 0.25, 0.5, and 0.25 on sequential observations, whereas @holiday("christmas[1,2,1]", "denorm") would return values 1, 2, and 1.
@holiday Examples
The command
series jan1 = @holiday("Jan1")
generates a series containing a non-zero value only for those observations associated with January 1st. For a daily or lower frequency workfile, only a single observation will cover January 1st each year and that observation will have a value of 1. For a higher frequency workfile, multiple observations will cover January 1st and thus have a value less than one. For example, in an intra-day workfile with a frequency of six hours, each of the four observations for January 1st every year will have the value 0.25.
series jan1early = @holiday("Jan1", "Mon-Sun,9AM-2PM")
generates a series that is non-zero only for those observations associated with January 1st and between the hours of 9AM (inclusive) and 3PM (exclusive). For an intra-day workfile with a frequency of six hours, the two observations for January 1st that begin at 6AM and noon each year will have the value 0.5. Note that the end time of the basis specification, e.g. 2PM, is considered to extend to the last moment of the specified time, thus 2PM is interpreted as 2:59:59.999PM (3PM rather than 2PM).
series mondays = @holiday("Nov1Mon(1)")
generates a series that is non-zero only for those observations that fall on the day after the first Monday in November, i.e. the Tuesday that is US federal Election Day.
series frenchlabor = @holiday("Labour.fr~")
Generates a series that is non-zero only for those observations associated with French Labor Day (May 1st). Should that day fall on a Saturday, the observation(s) for the preceding Friday will be non-zero instead, or if that day falls on a Sunday, the observation(s) for the following Monday will be non-zero. For example, in a daily workfile covering years 2020 through 2024, the observations for Friday May 1 2020, Friday April 30 2021, Monday May 2 2022, Monday May 1 2023, and Wednesday May 1 2024 would have the value 1.
series canadaday = @holiday("Canada!")
generates a series that is non-zero only for those observations associated with Canada Day (July 1st). Should that day fall on a Saturday or a Sunday, the observation(s) for the following Monday will be non-zero instead. For example, in a daily workfile covering years 2022 through 2024, the observations for Friday July 1 2022, Monday July 3 2023, and Monday July 1 2024 would have the value 1.
series lunar = @holiday("LNY~(-3)")
generates a series that is non-zero only for those observations occurring three days before the Lunar New Year, adjusted for weekends. For example, in a daily workfile covering year 2020, while the nominal date for the holiday is Saturday January 25, the observation for Tuesday January 21 would have the value 1 as a consequence of the weekend modifier and offset.
series newyears1 = @holiday("NewYears[1,2,0]")
generates a series that is non-zero only for those observations associated with New Year's Day (January 1st) and the preceding day (December 31st). In the common case where those two days will be covered by different observations, the observation for December 31st will have the value 0.33 and the observation for January 1st will have the value 0.67 given the relative weights specified.
series newyears2 = @holiday("NewYears[1,2,0]","denorm")
generates a series that is non-zero only for those observations associated with New Year's Day (January 1st) and the preceding day (December 31st). With the use of the “denorm” option, the observation for December 31st will have the value 1 and the observation for January 1st will have the value 2.
series ukbank = @holiday("Bank.uk!")
generates a series that is non-zero only for those observations associated with United Kingdom bank holidays included in the “bank.uk” named group. The weekend modifier “!” is applied to each individual holiday in the group.
series postvets = @holiday("Veterans.us(7) Thanksgiving.us")
generates a series that is non-zero only for those observations between a week after US Veterans Day and US Thanksgiving. This range normally covers between five to eleven days, depending on the year. For example, in 2020 this range covers nine days (November 18 through November 26), thus in daily workfile the observations associated with those days would have the value 0.111.
@holidayset Examples
The command
series jan1set = @holidayset("Jan1")
generates a series containing a non-zero value only for those observations associated with January 1st. For a daily or lower frequency workfile, only a single observation will cover January 1st each year and that observation will have a value of 1. For a higher frequency workfile, multiple observations will cover January 1st and thus have a value less than one. For example, in an intra-day workfile with a frequency of six hours, each of the four observations for January 1st every year will have the value 0.25. Since only a single holiday is specified, this function behaves identically to @holiday.
series vetsset = @holidayset("Veterans.us(7) Thanksgiving.us")
generates a series that is non-zero only for those observations a week after US Veterans Day and on US Thanksgiving. For example, in 2020 the two holidays occur on November 18 and November 26, thus in daily workfile the observations associated with those days would each have the value 0.5. Note that unlike the @holiday function, the two holidays included are distinct and do not specify a range.
series easterset = @holidayset("Easter Unity.de[ramp(3)] Oct31~")
generates a series that is non-zero only for those observations associated with Easter, the five days on and around German Unity Day, and Halloween, adjusted for weekends. For example, in a daily workfile covering year 2020, the observation for Sunday April 12 will have the value 0.333, the observations for Thursday October 1 through Monday October 5 will have the values 0.037, 0.074, 0.111, 0.074, and 0.037, respectively, and finally the observation for Friday October 30 will have the value 0.333.
Indicator Functions
These functions produce indicators for whether each observation satisfies a specific condition:
• @inlist(series, “list”): returns a dummy variable with a value of 1 for each observation of series equal to one of the values specified in list. list should be a quoted, space delimited list of values. For example, @inlist(name, “John Jack Susan”) returns a dummy variable equal to 1 for each observation where name matches either “John”, “Jack” or “Susan”.
• @between(
series, val1, val2): returns dummy variable equal to 1 for observations where series is greater than or equal to
val1 and less than or equal to
val2. For example,
@between(X, 0.4, 0.6) returns a dummy variable equal to 1 for each observation of X satisfying
.