Workfile Sample Information
Sample Index Functions
A key EViews feature is the ability to work with subsamples of observations. There are two common ways of defining a subsample of observations in a workfile. One method is to specify a set of (0, 1) (boolean) identifiers that indicate whether each observation in the workfile is included in the subsample. A second method is to specify a list of index values for the observations in the subsample.
In some cases, working with the boolean indicators is more convenient. In others, especially when the subsample is sparse and direct access to the observation is useful, working with the index values may be preferred.
EViews provides workfile functions that allow you to extract information from the workfile and workfile sample, and to convert between the two methods.
Current Sample Index (@pagesmplidx)
The @pagesmplidx function returns a vector object containing the index values for the observations in the current sample.
Suppose we have an annual workfile from 2001 to 2024, and have set the workfile sample to a subset of observations. The commands
wfcreate(wf=awf) a 2001 2024
smpl 2002 2003 2010 2011
create a workfile containing annual observations from 2001 to 2024, then sets the sample to contain observations from 2002–2003 and 2010–2011. There are 24 observations in this workfile which may be identified by index values 1 to 24. Then
vector ids = @pagesmplidx
will return IDS containing {2, 3, 10, 11}.
Observations Index (@pageidx)
The @pageidx(arg) function returns a vector object containing the index values for the observations in the workfile specified in arg.
The argument may be a vector of date numbers, an svector of date strings, or a string object or string literal containing a space delimited list of dates.
Observation specifications that are outside of the workfile range will be ignored.
For example,
wfcreate(wf=qwf) q 2001 2024
vector id1 = @pageidx("2010q2 2010q3 2021q1 2023q4")
creates a workfile containing quarterly data from 2001 to 2024 and an ID1 vector containing the values {38, 39, 81, 92}.
Boolean Indicators (@pageinidx)
The @pageinidx(arg) function, where arg is a vector containing observation index values, returns a vector object, sized to match the workfile page length, that includes (0, 1) indicators for each observation, with 1’s assigned to index elements in arg, and 0’s elsewhere.
If the arg contains index values that are outside of the workfile range, the function will return an error.
If we have the commands
vector id2 = @fill(10, 27, 30, 40)
vector incl = @pageinidx(id2)
then INC1 is a vector with 0’s everywhere except for the elements 10, 27, 30, and 40. Note that these commands are a concise equivalent to the commands
vector inc2 = @zeros(@wfrange)
inc2(10) = 1
inc2(17) = 1
inc2(30) = 1
inc2(40) = 1
Using @pageidx to identify observation indices and then feeding the result to @pageinidx offers a quick way of specifying a subsample of observations using dates:
wfcreate(wf=qwf) q 2001 2024
vector inc3 = @pageinidx(@pageidx("2010q2 2010q3 2021q1 2023q4")
stom(inc3, include_series)
smpl @all if include_series = 1