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:

• @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("date1 [date2]", [basis]): 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.

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 argument, basis, 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 event. basis should be enclosed in quotes and should follow a syntax of “start_weekday-end_weekday, start_time-end_time”. eg. use “Mon-Fri” to indicate that only days from Monday to Friday (inclusive) should be counted when proportioning up the event between observations.

• @holiday("date1 [date2]", [basis]): returns a variable containing the proportion of an annual event covered by each observation. The event can be specified by a single date, a date pair to denote a date range. When specifying a date, you may use one of the following special terms:

Day in a month eg. “Dec25”.

Day in a month, with Saturday moved back to Friday and Sunday moved forward to Monday (by using “~” after the day) e.g., “Dec25~”.

N-th weekday within a month (using negative values for last weekday in month). e.g., “Nov4Thu” for the fourth Thursday in November, and “May-1Mon” for the last Monday in May.

A specific holiday name: “Easter”, “Christmas”, “Thanksgiving”, “cny” (Chinese New Year).

You may optionally supply an offset to the specified holiday by including a number in parenthesis after the holiday. For example to specify a holiday of a range of dates covering three days before Easter to four days after Easter each year, use “Easter(-3) Easter(4).

The optional argument, basis, may be used In the @event and @holiday functions to specify that only certain days of the week, or times of the day should be included as part of the holiday event. basis should be enclosed in quotes and should follow a syntax of “start_weekday-end_weekday, start_time-end_time”. eg. use “Mon-Fri” to indicate that only days from Monday to Friday (inclusive) should be counted when proportioning up the event between observations.

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 .