Function Reference: O
@obs Number of observations.
@obsby Number of non-missing observations in a series or alpha, for each specified group.
@obsid Sequential index for the observation in the workfile.
@obsrange Number of observations in the workfile page.
@obssmpl Number of observations in the workfile sample.
@ones Matrix or vector of ones.
@option Option string provided in the
exec or
run command.
@otod Workfile observation to date string.
@otods Sample observation to date string.
@outer Outer product of vectors or series.
Number of observations.
Number of non-missing observations
in
.Syntax: @obs(x[, s])
x: series, vector, matrix
s: (optional) sample string or object when x is a series and assigning to a series
Return: number
For series calculations, EViews will use the current or specified workfile sample.
Examples
If x is a series of length 5 with elements 1, NA, 2, NA, 3, then
= @obs(x)
returns 3.
Cross-references
Number of non-missing observations in a series or alpha, for each specified group.
Syntax: @obsby(x, y[y1, y2, ... yn, s])
x: series, alpha
y series, alpha
s: (optional) sample string or object
Return: series
Compute the number of non-missing values in x for groups defined by distinct values of y.
EViews will use the current or specified workfile sample.
Examples
show @obsby(x, g1, g2)
produces a linked series of by-group non-NA counts in the series x, where members of the same group have identical values for both g1 and g2.
Cross-references
Sequential index for observation in workfile.
Syntax: @obsid
Return: series
Return the sequentially assigned observation number for each observation in the workfile.
The observation index is panel aware. For panel workfiles, the observation numbers are not associated with any particular value of within cross-section identifiers.
Examples
wfcreate a 2001 2022
series ids = @obsid
returns a series with sequential values 1 to 22.
smpl if @mod(@obsid, 5) = 0
sets the workfile sample to every fifth observation.
Cross-references
Number of observations in the current workfile page.
Syntax: @obsrange
Return: integer
Examples
scalar wflen = @obsrange
saves the workfile length in the scalar WFLEN.
The commands
smpl if @obsid < @obsrange*.8
equation eq1.ls y c x1 x2 x3
eq1.forecast(f=na, forcsmpl="if @obsid >= @obsrange*.8") eq1f
sets the sample to (approximately) the first 80% of the workfile sample, estimates an equation, then forecasts for the last 20% of the workfile.
Cross-references
See also
@obssmpl and
@obsid.
Number of observations in the current workfile sample.
Syntax: @obssmpl
Return: integer
Examples
The following set of commands
workfile u 1000
series y = nrnd
smpl if @abs(y) < 1.2
scalar trim = @obssmpl
creates a workfile, sets a sample based on values of randomly generated Y then creates a scalar object TRIM containing the number of Y observations with absolute values less than 1.2.
Cross-references
See also
@obsrange and
@obsid.
Matrix or vector of ones.
Syntax: @ones(n1[, n2])
n1: integer
n2: (optional) integer
Return: matrix, vector
Creates a matrix or vector filled with the value 1. The size of the created matrix is given by the integers n1 (number of rows) and n2 (number of columns).
Examples
matrix m1 = @ones(3,2)
creates M1, a

matrix of ones.
sym s1 = @ones(5, 5)
sym s2 = @unvech(@ones(5*6/2))
create

symmetric matrices of ones, while
vector v1 = @ones(18)
is an 18-element vector of ones, and
matrix k4 = @kronecker(@fill(1, 2, 3), @ones(4, 4))
generates the

matrix formed by taking the Kronecker product of a column vector whose elements are 1, 2, and 3, and a

matrix of ones.
Cross-references
Option string in an exec or run command.
Syntax: @option(arg)
arg: integer
Return: string
returns the
i-th option provided in the
exec or
run command.
Cross-references
Workfile observation to date string.
Syntax: @otod(n)
n: integer
Return: string
Returns a string identifying the date or observation corresponding to observation number n, counted from the beginning of the current workfile. Invalid inputs will produce an empty string.
EViews will use the global default settings for the to determine the ordering of days and months in the resulting date string.
Examples
For example, consider the string assignment
@otod(5)
For an annual workfile dated 1991–2000, the function returns the string “1995”. For a quarterly workfile dated 1970q1–2000q4, the function returns “1971q1”.
@otod(1)
returns the date or observation label for the start of the workfile.
If the series DSER contains integer workfile observation numbers,
alpha aser = @dtoo(dser)
fills ASER with string dates corresponding to the workfile observation numbers for each observation in the workfile sample.
If DVEC is a a vector containing integer observations numbers, the command
vector avec = @dtoo(dvec)
fills AVEC with the date strings corresponding to the workfile observation numbers in DVEC.
Cross-references
See also
@otods and
@dtoo.
Sample observation to date string.
Syntax: @otods(n)
n: integer, series, vector
Return: string, alpha, svector
Returns a string containing the date or observation corresponding to observation number n, counted from the beginning of the current workfile sample.
EViews will use the global default settings for the to determine the ordering of days and months in the resulting date string.
Examples
Thus
@otods(2)
will return the date associated with the second observation in the current sample. Note that if n is negative, or is greater than the number of observations in the current sample, an empty string will be returned.
If the series DSER contains integer sample observation numbers,
alpha aser = @otods(dser)
fills ASER with string dates corresponding to the given numbers for each observation in the workfile sample.
If DVEC is a vector containing integer observation numbers, the command
vector avec = @otods(dvec)
fills AVEC with the date strings corresponding to the workfile observation numbers in DVEC.
Cross-references
See also
@otod and
@dtoo.
Outer product of vectors or series.
Syntax: @outer(v1, v2)
v1: vector, series
v2: vector, series
Return: matrix
Returns the outer product of the two vectors or series. If used with two vectors, @outer requires that v1 and v2 be the same size.
• If used with two series, @outer returns a square matrix of every possible product of the elements of the two inputs. For series calculations, EViews will use the entire workfile.
• If used with two vectors,
@outer computes

. If
v1 and
v2 are column vectors, the result is the square matrix of every possible product of the elements of the two inputs. If
v1 and
v2 are row vectors, the result is a scalar containing the sum of the element products.
Examples
vector v1 = @fill(1, 2, 3)
vector v2 = @fill(4, 5, 6)
matrix m1 = @outer(v1, v2)
produces a

outer product matrix M1,
workfile u 100
series x = nrnd
series y = nrnd
matrix m2 = @outer(x, y)
creates an undated workfile with 100 observations, two series of IID standard normal numbers X and Y, and a

outer product matrix M1.
If you wish to compute the outer product of two series objects for a subset of observations, you will first have to extract the data to a sub-vector:
smpl 1 10
stom(x, vx)
stom(y, vy)
matrix m3 = @outer(vx, vy)
matrix m4 = m2.@sub(@range(1, 10), @range(1, 10))
produces identical

outer products for the first 10 observations in the workfile in M3 and M4.
Cross-references
See also
@inner and
@qform.