Sym
Symmetric matrix (symmetric two-dimensional array).
Sym Declaration
Declare by providing a name after the sym keyword, with the optionally specified dimension in parentheses:
sym(10) symmatrix
You may optionally assign a scalar, a square matrix or another sym in the declaration. If the square matrix is not symmetric, the sym will contain the lower triangle. The sym will be sized and initialized accordingly.
Sym Views
cor correlation matrix by columns.
cov covariance matrix by columns.
eigen eigenvalues calculation for a symmetric matrix.
label label information for the symmetric matrix.
sheet spreadsheet view of the symmetric matrix.
stats descriptive statistics by column.
Sym Procs
clearhist clear the contents of the history attribute.
copy creates a copy of the sym.
export save sym matrix as Excel 2007 XLSX, CSV, tab-delimited ASCII text, RTF, HTML, Enhanced Metafile, PDF, TEX, or MD file on disk.
fill fill the elements of the matrix.
import imports data from a foreign file into the sym object.
label label information for the symmetric matrix.
olepush push updates to OLE linked objects in open applications.
read (deprecated) import data from disk.
setattr set the value of an object attribute.
setformat set the display format for the sym spreadsheet.
setindent set the indentation for the sym spreadsheet.
setjust set the horizontal justification for all cells in the spreadsheet view of the sym object.
setwidth set the column width in the sym spreadsheet.
showlabels displays the custom row and column labels of a sym spreadsheet.
write export data to disk.
Sym Graph Views
Graph creation views are discussed in detail in
“Graph Creation Command Summary”.
area area graph of the columns of the matrix.
bar bar graph of each column against the row index.
hilo high-low(-open-close) chart.
line line graph of each column against the row index.
qqplot quantile-quantile graph.
Sym Data Members
String values
@attr("arg") string containing the value of the arg attribute, where the argument is specified as a quoted string.
@collabels string containing the column labels of the sym.
@description string containing the Sym object’s description (if available).
@detailedtype string with the object type: “SCALAR”.
@displayname string containing the Sym object’s display name. If the Sym has no display name set, the name is returned.
@name string containing the Sym object’s name.
@remarks string containing the Sym object’s remarks (if available).
@rowlabels string containing the row labels of the sym.
@type string with the object type: “SCALAR”.
@updatetime string representation of the time and date at which the Sym was last updated.
Scalar values
(i,j) (i,j)-th element of the sym. Simply append “(i,j)” to the sym name (without a “.”).
@cols number of columns in the sym.
@rows number of rows in the sym.
Matrix values
@col(arg) Returns the columns defined by arg. arg may be an integer, vector of integers, string, or svector of strings. Integers correspond to column numbers so that, for example, arg = 2 specifies the second column. Strings correspond to column labels so that arg = "2" specifies the first column labeled “2”.
@diag vector containing the diagonal elements of the sym.
@drop(arg) Returns the sym with the rows and columns defined by arg removed. arg may be an integer, vector of integers, string, or svector of strings. Integers correspond to row and column numbers so that, for example, arg = 2 specifies the second row and column. Strings correspond to row and column labels so that arg = "2" specifies the first row and column labeled “2”.
@dropboth(arg1, arg2) Returns the matrix with the rows defined by arg1 and columns defined by arg2 removed. The args may be integers, vectors of integers, strings, or svectors of strings. Integers correspond to row or column numbers so that, for example, arg1 = 2 specifies the second row. Strings correspond to row or column labels so that arg2 = "2" specifies the first column labeled “2”.
@dropcol(arg) Returns the matrix with the columns defined by arg removed. arg may be an integer, vector of integers, string, or svector of strings. Integers correspond to column numbers so that, for example, arg = 2 specifies the second column. Strings correspond to column labels so that arg = "2" specifies the first column labeled “2”.
@droprow(arg) Returns the matrix with rows defined by arg removed. arg may be an integer, vector of integers, string, or svector of strings. Integers correspond to row numbers so that, for example, arg = 2 specifies the second row. Strings correspond to row labels so that arg = "2" specifies the first row labeled “2”.
@icol(arg) Returns the indices for the columns defined by arg where arg is a string or svector of strings. The strings correspond to column labels so that arg = "2" specifies the first column labeled “2”.
@irow(arg) Returns the indices for the rows defined by arg where arg is a string or svector of strings. The strings correspond to row labels so that arg = "2" specifies the first row labeled “2”.
@row(arg) Returns the rows defined by arg. arg may be an integer, vector of integers, string, or svector of strings. Integers correspond to row numbers so that, for example, arg = 2 specifies the second row. Strings correspond to row labels so that arg = "2" specifies the first row labeled “2”.
@ssub(arg) Returns the sym with rows and columns defined by arg. arg may be an integer, vector of integers, string, or svector of strings. Integers correspond to row and column numbers so that, for example, arg = 2 specifies the second row and column. Strings correspond to row and column labels so that arg = "2" specifies the first row and column labeled “2”.
@sub(arg1, arg2) Returns the matrix with rows defined by arg1 and columns defined by arg2. The args may be integers, vectors of integers, strings, or svectors of strings. Integers correspond to row or column numbers so that, for example, arg1 = 2 specifies the second row. Strings correspond to row or column labels so that arg2 = "2" specifies the first column labeled “2”.
@t Returns transpose (copy) of the sym.
Sym Examples
The declaration:
sym results(10)
results=3
creates the

matrix
RESULTS and initializes each value to be 3. The following assignment statements also create and initialize sym objects:
sym copymat=results
sym covmat1=eq1.@coefcov
sym(3,3) count
count.fill 1,2,3,4,5,6,7,8,9,10
Graphs, covariances, and statistics may be generated for the columns of the matrix:
copymat.line
copymat.cov
copymat.stats
You can use explicit indices to refer to matrix elements:
scalar diagsum=cov1(1,1)+cov1(2,2)+cov(3,3)
Clear the column label in a sym object.
Syntax
sym_name.clearcollabels
Examples
sym1.clearcollabels
clears the custom column label from the sym SYM1.
Cross-references
Clear the contents of the history attribute.
Removes the sym’s history attribute, as shown in the label view of the sym.
Syntax
sym_name.clearhist
Examples
s1.clearhist
s1.label
The first line removes the history from the sym S1, and the second line displays the label view of S1, including the now blank history field.
Cross-references
See
“Labeling Objects” for a discussion of labels and display names.
Clear the contents of the remarks attribute.
Removes the sym’s remarks attribute, as shown in the label view of the sym.
Syntax
sym_name.clearremarks
Examples
s1.clearremarks
s1.label
The first line removes the remarks from the sym S1, and the second line displays the label view of S1, including the now blank remarks field.
Cross-references
See
“Labeling Objects” for a discussion of labels and display names.
Clear the row labels in a sym object.
Syntax
sym_name.clearrowlabels
Examples
sym1.clearrowlabels
clears the custom row labels from the sym SYM1.
Cross-references
Creates a copy of the sym.
Creates either a named or unnamed copy of the sym.
Syntax
sym_name.copy
sym_name.copy dest_name
Examples
s1.copy
creates an unnamed copy of the sym S1.
s1.copy s2
creates S2, a copy of the sym S1.
Cross-references
Compute covariances, correlations, and other measures of association for the columns in a matrix.
You may compute measures related to Pearson product-moment (ordinary) covariances and correlations, Spearman rank covariances, or Kendall’s tau along with test statistics for evaluating whether the correlations are equal to zero.
Syntax
matrix_name.cor(options) [keywords [@partial z1 z2 z3...]]
You should specify keywords indicating the statistics you wish to display from the list below, optionally followed by the keyword @partial and a list of conditioning series or groups (for the group view), or the name of a conditioning matrix (for the matrix view). In the matrix view setting, the columns of the matrix should contain the conditioning information, and the number or rows should match the original matrix.
You may specify keywords from one of the four sets (Pearson correlation, Spearman correlation, Kendall’s tau, Uncentered Pearson) corresponding the computational method you wish to employ. (You may not select keywords from more than one set.)
If you do not specify
keywords, EViews will assume “corr” and compute the Pearson correlation matrix. Note that
Sym::cor is equivalent to the
Sym::cov command with a different default setting.
Pearson Correlation
cov | Product moment covariance. |
corr | Product moment correlation. |
sscp | Sums-of-squared cross-products. |
stat | Test statistic (t-statistic) for evaluating whether the correlation is zero. |
prob | Probability under the null for the test statistic. |
cases | Number of cases. |
obs | Number of observations. |
wgts | Sum of the weights. |
Spearman Rank Correlation
rcov | Spearman’s rank covariance. |
rcorr | Spearman’s rank correlation. |
rsscp | Sums-of-squared cross-products. |
rstat | Test statistic (t-statistic) for evaluating whether the correlation is zero. |
rprob | Probability under the null for the test statistic. |
cases | Number of cases. |
obs | Number of observations. |
wgts | Sum of the weights. |
Kendall’s tau
taub | Kendall’s tau-b. |
taua | Kendall’s tau-a. |
taucd | Kendall’s concordances and discordances. |
taustat | Kendall’s score statistic for evaluating whether the Kendall’s tau-b measure is zero. |
tauprob | Probability under the null for the score statistic. |
cases | Number of cases. |
obs | Number of observations. |
wgts | Sum of the weights. |
Uncentered Pearson
ucov | Product moment covariance. |
ucorr | Product moment correlation. |
usscp | Sums-of-squared cross-products. |
ustat | Test statistic (t-statistic) for evaluating whether the correlation is zero. |
uprob | Probability under the null for the test statistic. |
cases | Number of cases. |
obs | Number of observations. |
wgts | Sum of the weights. |
Note that cases, obs, and wgts are available for each of the methods.
Options
wgt=name (optional) | Name of vector containing weights. The number of rows of the weight vector should match the number of rows in the original matrix. |
wgtmethod=arg (default = “sstdev”) | Weighting method (when weights are specified using “weight=”): frequency (“freq”), inverse of variances (“var”), inverse of standard deviation (“stdev”), scaled inverse of variances (“svar”), scaled inverse of standard deviations (“sstdev”). Only applicable for ordinary (Pearson) calculations. Weights specified by “wgt=” are frequency weights for rank correlation and Kendall’s tau calculations. |
pairwise | Compute using pairwise deletion of observations with missing cases (pairwise samples). |
df | Compute covariances with a degree-of-freedom correction to account for estimated means (for centered specifications), and any partial conditioning variables. |
multi=arg (default=“none”) | Adjustment to p-values for multiple comparisons: none (“none”), Bonferroni (“bonferroni”), Dunn-Sidak (“dunn”). |
outfmt=arg (default= “single”) | Output format: single table (“single”), multiple table (“mult”), list (“list”), spreadsheet (“sheet”). Note that “outfmt=sheet” is only applicable if you specify a single statistic keyword. |
out=name | Basename for saving output. All results will be saved in Sym matrices named using keys (“COV”, “CORR”, “SSCP”, “TAUA”, “TAUB”, “CONC” (Kendall’s concurrences), “DISC” (Kendall’s discordances), “CASES”, “OBS”, “WGTS”) appended to the basename (e.g., the covariance specified by “out=my” is saved in the Sym matrix “MYCOV”). |
prompt | Force the dialog to appear from within a program. |
p | Print the result. |
Examples
sym1.cor
displays a

Pearson correlation matrix for the columns series in
MAT1.
sym1.cor corr stat prob
displays a table containing the Pearson correlation, t-statistic for testing for zero correlation, and associated p-value, for the columns in MAT1.
sym1.cor(pairwise) taub taustat tauprob
computes the Kendall’s tau-b, score statistic, and p-value for the score statistic, using samples with pairwise missing value exclusion.
Cross-references
See also
Sym::cov. For simple forms of the calculation, see
@cor, and
@cov.
Compute covariances, correlations, and other measures of association for the columns in a matrix.
You may compute measures related to Pearson product-moment (ordinary) covariances and correlations, Spearman rank covariances, or Kendall’s tau along with test statistics for evaluating whether the correlations are equal to zero.
Syntax
matrix_name.cov(options) [keywords [@partial z1 z2 z3...]]
You should specify keywords indicating the statistics you wish to display from the list below, optionally followed by the keyword @partial and a list of conditioning series or groups (for the group view), or the name of a conditioning matrix (for the matrix view). In the matrix view setting, the columns of the matrix should contain the conditioning information, and the number or rows should match the original matrix.
You may specify keywords from one of the four sets (Pearson correlation, Spearman rank correlation, Kendall’s tau, Uncentered Pearson) corresponding the computational method you wish to employ. (You may not select keywords from more than one set.)
If you do not specify
keywords, EViews will assume “cov” and compute the Pearson covariance matrix. Note that
Sym::cov is equivalent to the
Sym::cor command with a different default setting.
Pearson Correlation
cov | Product moment covariance. |
corr | Product moment correlation. |
sscp | Sums-of-squared cross-products. |
stat | Test statistic (t-statistic) for evaluating whether the correlation is zero. |
prob | Probability under the null for the test statistic. |
cases | Number of cases. |
obs | Number of observations. |
wgts | Sum of the weights. |
Spearman Rank Correlation
rcov | Spearman’s rank covariance. |
rcorr | Spearman’s rank correlation. |
rsscp | Sums-of-squared cross-products. |
rstat | Test statistic (t-statistic) for evaluating whether the correlation is zero. |
rprob | Probability under the null for the test statistic. |
cases | Number of cases. |
obs | Number of observations. |
wgts | Sum of the weights. |
Kendall’s tau
taub | Kendall’s tau-b. |
taua | Kendall’s tau-a. |
taucd | Kendall’s concordances and discordances. |
taustat | Kendall’s score statistic for evaluating whether the Kendall’s tau-b measure is zero. |
tauprob | Probability under the null for the score statistic. |
cases | Number of cases. |
obs | Number of observations. |
wgts | Sum of the weights. |
Uncentered Pearson
ucov | Product moment covariance. |
ucorr | Product moment correlation. |
usscp | Sums-of-squared cross-products. |
ustat | Test statistic (t-statistic) for evaluating whether the correlation is zero. |
uprob | Probability under the null for the test statistic. |
cases | Number of cases. |
obs | Number of observations. |
wgts | Sum of the weights. |
Note that cases, obs, and wgts are available for each of the methods.
Options
wgt=name (optional) | Name of vector containing weights. The number of rows of the weight vector should match the number of rows in the original matrix. |
wgtmethod=arg (default = “sstdev”) | Weighting method (when weights are specified using “weight=”): frequency (“freq”), inverse of variances (“var”), inverse of standard deviation (“stdev”), scaled inverse of variances (“svar”), scaled inverse of standard deviations (“sstdev”). Only applicable for ordinary (Pearson) calculations. Weights specified by “wgt=” are frequency weights for rank correlation and Kendall’s tau calculations. |
pairwise | Compute using pairwise deletion of observations with missing cases (pairwise samples). |
df | Compute covariances with a degree-of-freedom correction to account for estimated means (for centered specifications), and any partial conditioning variables. |
multi=arg (default=“none”) | Adjustment to p-values for multiple comparisons: none (“none”), Bonferroni (“bonferroni”), Dunn-Sidak (“dunn”). |
outfmt=arg (default=“single”) | Output format: single table (“single”), multiple table (“mult”), list (“list”), spreadsheet (“sheet”). Note that “outfmt=sheet” is only applicable if you specify a single statistic keyword. |
out=name | Basename for saving output. All results will be saved in Sym matrices named using keys (“COV”, “CORR”, “SSCP”, “TAUA”, “TAUB”, “CONC” (Kendall’s concurrences), “DISC” (Kendall’s discordances), “CASES”, “OBS”, “WGTS”) appended to the basename (e.g., the covariance specified by “out=my” is saved in the Sym matrix “MYCOV”). |
prompt | Force the dialog to appear from within a program. |
p | Print the result. |
Examples
sym1.cov
displays a

Pearson covariance matrix for the columns series in
MAT1.
sym1.cov corr stat prob
displays a table containing the Pearson covariance, t-statistic for testing for zero correlation, and associated p-value, for the columns in MAT1.
sym1.cov(pairwise) taub taustat tauprob
computes the Kendall’s tau-b, score statistic, and p-value for the score statistic, using samples with pairwise missing value exclusion.
Cross-references
See also
Sym::cor. For simple forms of the calculation, see
@cor, and
@cov.
Display table, graph, or spool output in the sym object window.
Display the contents of a table, graph, or spool in the window of the sym object.
Syntax
sym_name.display object_name
Examples
sym1.display tab1
Display the contents of the table TAB1 in the window of the object SYM1.
Cross-references
Most often used in constructing an EViews Add-in. See
“Custom Object Output”.
Display name for symmetric matrix objects.
Attaches a display name to a symmetric matrix object which may be used to label output in place of the standard matrix object name.
Syntax
matrix_name.displayname display_name
Display names are case-sensitive, and may contain a variety of characters, such as spaces, that are not allowed in matrix object names.
Examples
s1.displayname Hours Worked
s1.label
The first line attaches a display name “Hours Worked” to the symmetric matrix object S1, and the second line displays the label view of S1, including its display name.
Cross-references
See
“Labeling Objects” for a discussion of labels and display names.
Eigenvalues calculation for a symmetric matrix.
Syntax
There are two forms of the eigen command.
The first form, which applies when displaying eigenvalue table output or graphs of the ordered eigenvalues, has only options and no command argument.
sym_name.eigen(options)
The second form, which applies to the graphs of component loadings (specified with the option “out=loadings”) uses an optional argument to determine which components to plot. In this form:
sym_name.eigen(options) [graph_list]
where the graph_list is an optional list of integers and/or vectors containing integers identifying the components to plot. Multiple pairs are handled using the method specified in the “mult=” option.
If the list of component indices omitted, EViews will plot only first and second components. Note that the order of elements in the list matters; reversing the order of two indices reverses the axis on which each component is displayed.
Options
out=arg (default=“table”) | Output: table of eigenvalue and eigenvector results (“out=table”), graphs of ordered eigenvalues (“graph”), graph of the eigenvectors (“loadings”). Note: when specifying the eigenvalue graph (“out=graph”), the option keywords “scree” (scree graph), “diff” (difference in successive eigenvalues), and “cproport” (cumulative proportion of total variance) may be included to control the output. By default, EViews will display the scree graph. If you specify one or more of the keywords, EViews will construct the graph using only the specified types (i.e., if you specify “cproport”, a scree plot will not be provided unless requested). |
n=integer | Maximum number of components to retain when presenting table (“out=table”) or eigenvalue graph (“out=graph”) results. The default is to set  to the number of variables. EViews will retain the minimum number satisfying any of: “n=”, “mineig=” or “cproport=”. |
mineig=arg (default=0) | Minimum eigenvalue threshold value: we retain components with eigenvalues that are greater than or equal to the threshold. EViews will retain the minimum number satisfying any of: “n=”, “mineig=” or “cproport=”. |
cproport=arg (default = 1) | Cumulative proportion threshold value: we retain  , the number of components required for the sum of the first  eigenvalues exceeds the specified value for the cumulative variance explained proportion. EViews will retain the minimum number satisfying any of: “n=”, “mineig=” or “cproport=”. |
eigval=vec_name | Specify name of vector to hold the saved the eigenvalues in workfile. |
eigvec=mat_name | Specify name of matrix to hold the save the eigenvectors in workfile. |
prompt | Force the dialog to appear from within a program. |
p | Print results. |
Graph Options
scale=arg, (default=“normload”) | Diagonal matrix scaling of the loadings: normalize loadings (“normload”), normalize scores (“normscores”), symmetric weighting (“symmetric”), user-specified power (arg=number). |
mult =arg (default=“first”) | Multiple series handling: plot first against remainder (“first”), plot as x-y pairs (“pair”), lower-triangular plot (“lt”). |
nocenter | Do not center graphs around the origin. |
Examples
sym s1 = @cov(g1)
freeze(tab1) s1.eigen(method=cor, eigval=v1, eigvec=m1)
The first line creates a group named g1 containing the four series x1, x2, x3, x4. The second line computes the correlation matrix S1 from the series in G1. The final line stores the table view of the eigenvalues and eigenvectors of S1 in a table object named tab1, the eigenvalues in a vector named v1, and the eigenvectors in a matrix named m1.
Cross-references
See
“Principal Components” for a discussion of principal components analysis on a group of series, which describes a superset of the tools for eigenvalue calculations offered by the sym matrix.
Export sym to disk as an Excel 2007 XLSX, CSV, tab-delimited ASCII text, RTF, HTML, Enhanced Metafile, LaTeX, PDF, or Markdown file.
Syntax
sym_name.export(options) [path\]file_name
Follow the keyword with a name for the file. file_name may include the file type extension, or the file type may be specified using the “t=” option.
If an explicit path is not specified, the file will be stored in the default directory, as set in the global options.
The base syntax for writing Excel 2007 files is:
sym_name.export(options) [path\]file_name [table_description]
where the table_description may contain:
• “range = arg”, where arg is top left cell of the destination Excel workbook, following the standard Excel format [worksheet!][topleft_cell[:bottomright_cell]].
If the worksheet name contains spaces, it should be placed in single quotes. If the worksheet name is omitted, the cell range is assumed to refer to the currently active sheet. If only a top left cell is provided, a bottom right cell will be chosen automatically to cover the range of non-empty cells adjacent to the specified top left cell. If only a sheet name is provided, the first set of non-empty cells in the top left corner of the chosen worksheet will be selected automatically. As an alternative to specifying an explicit range, a name which has been defined inside the Excel workbook to refer to a range or cell may be used to specify the cells to read.
Options
t=file_type (default=“csv”) | Specifies the file type, where file_type may be one of: “excelxml” (Excel 2007 (xml)),“csv” (CSV - comma-separated), “rtf” (Rich-text format), “txt” (tab-delimited text), “html” (HTML - Hypertext Markup Language), “emf” (Enhanced Metafile), “pdf” (PDF - Portable Document Format), “tex” (LaTeX), or “md” (Markdown). Files will be saved with the “.xlsx”, “.csv”, “.rtf”, “.txt”, “.htm”, “.emf”, “.pdf”, “.tex”, or “.md” extensions, respectively. |
s=arg | Scale size, where arg is from 5 to 200, representing the percentage of the original table size (only valid for HTML or RTF files). |
n=string | Replace all cells that contain NA values with the specified string. “NA” is the default. |
h / -h | Include(/do not include) column and row headers. The default is to not include the headers |
prompt | Force the dialog to appear from within a program. |
PDF Options
landscape | Save in landscape mode (the default is to save in portrait mode). |
size=arg (default=“letter”) | Page size: “letter”, “legal”, “a4”, and “custom”. |
width=number (default=8.5) | Page width in inches if “size=custom”. |
height=number (default=11) | Page height in inches if “size=custom”. |
leftmargin=number (default=0.5) | Left margin width in inches. |
rightmargin=number (default = 0.5) | Right margin width in inches. |
topmargin=number (default=1) | Top margin width in inches. |
bottommargin= number (default = 1) | Bottom margin width in inches. |
LaTeX Options
texspec / -texspec | [Include / Do not include] the full LaTeX documentation specification in the LaTeX output. The default behavior is taken from the global default settings. |
Excel Options
mode=arg | Specify whether to create a new file, overwrite an existing file, or update an existing file. arg may be “create” (create new file only; error on attempt to overwrite) or “update” (update an existing file, only overwriting the area specified by the range= table_description). If the “mode=” option is not used, EViews will create a new file, unless the file already exists in which case it will overwrite it. Note that the “mode=update” option is only available for Excel in 1) Excel versions through 2003, if Excel is installed, and 2) Excel 2007 (xml). Note: Excel does not need to be installed for Excel 2007 writing. |
Excel 2007 Options
mode=arg | Specify whether to create a new file, overwrite an existing file, or update an existing file. arg may be “create” (create new file only; error on attempt to overwrite) or “update” (update an existing file, only overwriting the area specified by the range= table_description). If the “mode=” option is not used, EViews will create a new file, unless the file already exists in which case it will overwrite it. Note that the “mode=update” option is only available for Excel in 1) Excel versions through 2003, if Excel is installed, and 2) Excel 2007 (xml). Note: Excel does not need to be installed for Excel 2007 writing. |
cellfmt=arg | Specify whether to use EViews, pre-existing, or remove cell formatting (colors, font, number formatting when possible, column widths and row heights) for the written range. arg may be “eviews” (replace current formatting in the file with the same cell formatting in EViews), “preserve” (leave current cell formatting already in the Excel file), or “clear” (remove current formatting and do not replace). |
strlen=arg (default = 256) | Specify the maximum the number of characters written for cells containing text. Strings in cells which are longer the max, will be truncated. |
Examples
The command:
sym1.export mysym
exports the data in SYM1 to a CSV file named “mysym.CSV” in the default directory.
sym1.export(h, t=csv, n="NaN") mysym
saves the contents of SYM1 along with the column and row headers to a CSV (comma separated value) file named “mysym.CSV” and writes all NA values as “NaN”.
sym1.export(h, t=html, s=50) mysym
exports the data in SYM1 along with the column and row headers to a HTML file named “mysym.HTM” at half of the original size.
sym1.export(n=".", r=B) mysym
saves the data in the second column to a CSV file named “mysym.CSV”, and writes all NA values as “.”.
sym1.export(t=excelxml, cellfmt=clear, mode=update) mysym range=Country!b5
writes the data in SYM1 to the preexisting “mysym.XLSX” Excel file to the “Country” sheet at cell B5, where all cell formatting is cleared.
Cross-references
Fill a symmetric matrix object with specified values.
Syntax
matrix_name.fill(options) n1[, n2, n3 …]
Follow the keyword with a list of values to place in the specified object. Each value should be separated by a comma.
Running out of values before the object is completely filled is not an error; the remaining cells or observations will be unaffected, unless the “l” option is specified. If, however, you list more values than the object can hold, EViews will not modify any observations and will return an error message.
Options
l | Loop repeatedly over the list of values as many times as it takes to fill the object. |
o=integer (default=1) | Fill the object from the specified element. Default is the first element. |
Examples
The commands,
sym(2) m1
m1.fill 0, 1, 2
create the symmetric matrix:
 | (1.5) |
Cross-references
See
“Matrix Language” for a detailed discussion of vector and matrix manipulation in EViews.
Imports data from a foreign file into the sym object.
Syntax
sym_name.import([type=]) source_description import_specification
• source_description should contain a description of the file from which the data is to be imported. The specification of the description is usually just the path and file name of the file, however you can also specify more precise information. See
wfopen for more details on the specification of
source_description.
• The optional “type=” option may be used to specify a source type. For the most part, you should not need to specify a “type=” option as EViews will automatically determine the type from the filename. The following table summaries the various source formats and along with the corresponding “type=” keywords:
| |
Excel (through 2003) | “excel” |
Excel 2007 (xml) | “excelxml” |
HTML | “html” |
Text / ASCII | “text” |
• import_specification can be used to provide additional information about the file to be read. The details of import_specification will depend upon the type of file being imported.
Excel Files
The syntax for reading Excel files is:
sym_name.import(type=excel[xml]) source_description [table_description] [variables_description]
The following table_description elements may be used when reading Excel data:
• “range = arg”, where arg is a range of cells to read from the Excel workbook, following the standard Excel format [worksheet!][topleft_cell[:bottomright_cell]].
If the worksheet name contains spaces, it should be placed in single quotes. If the worksheet name is omitted, the cell range is assumed to refer to the currently active sheet. If only a top left cell is provided, a bottom right cell will be chosen automatically to cover the range of non-empty cells adjacent to the specified top left cell. If only a sheet name is provided, the first set of non-empty cells in the top left corner of the chosen worksheet will be selected automatically. As an alternative to specifying an explicit range, a name which has been defined inside the excel workbook to refer to a range or cell may be used to specify the cells to read.
• “byrow”, transpose the incoming data. This option allows you to read files where the series are contained in rows (one row per series) rather than columns.
The optional variables_description may be formed using the elements:
• “colhead=int”, number of table rows to be treated as column headers.
• “na="arg1"”, text used to represent observations that are missing from the file. The text should be enclosed on double quotes.
• “scan=[int| all]”, number of rows of the table to scan during automatic format detection (“scan=all” scans the entire file). Note: If a "range=" argument is not specified, then EViews will only scan the first five rows of data to try and determine the data format for each column. Likewise, if the "na=" argument is not specified, EViews will also try to determine possible NA values by looking for repeated values in the same rows. If the first five rows are not enough to correctly determine the data format, use the "scan=" argument to instruct EViews to look at more rows. In addition, you may want to specify a the "na=" value to override any dynamic NA value that EViews may determine on its own.
• “firstobs=int”, first observation to be imported from the data (default is 1). This option may be used to start reading rows from partway through the table.
• “lastobs = int”, last observation to be read from the data (default is last observation of the file). This option may be used to read only part of the file, which may be useful for testing.
Excel Examples
sym_obj.import "c:\data files\data.xls"
loads the active sheet of DATA.XLSX into the SYM_NAME sym object.
sym_obj.import "c:\data files\data.xls" range="GDP data"
reads the data contained in the “GDP data” sheet of “Data.XLS” into the SYM_OBJ object.
HTML Files
The syntax for reading HTML pages is:
sym_name.import(type=html) source_description [table_description] [variables_description]
The following table_description elements may be used when reading an HTML file or page:
• “table = arg”, where arg specifies which HTML table to read in an HTML file/page containing multiple tables.
When specifying arg, you should remember that tables are named automatically following the pattern “Table01”, “Table02”, “Table03”, etc. If no table name is specified, the largest table found in the file will be chosen by default. Note that the table numbering may include trivial tables that are part of the HTML content of the file, but would not normally be considered as data tables by a person viewing the page.
• “skip = int”, where int is the number of rows to discard from the top of the HTML table.
• “byrow”, transpose the incoming data. This option allows you to import files where the series are contained in rows (one row per series) rather than columns.
The optional variables_description may be formed using the elements:
• “colhead=int”, number of table rows to be treated as column headers.
• “na="arg1"”, text used to represent observations that are missing from the file. The text should be enclosed on double quotes.
• “scan=[int|all]”, number of rows of the table to scan during automatic format detection (“scan=all” scans the entire file). Note: If a "range=" argument is not specified, then EViews will only scan the first five rows of data to try and determine the data format for each column. Likewise, if the "na=" argument is not specified, EViews will also try to determine possible NA values by looking for repeated values in the same rows. If the first five rows are not enough to correctly determine the data format, use the "scan=" argument to instruct EViews to look at more rows. In addition, you may want to specify a the "na=" value to override any dynamic NA value that EViews may determine on its own.
• “firstobs=int”, first observation to be imported from the table of data (default is 1). This option may be used to start reading rows from partway through the table.
• “lastobs = int”, last observation to be read from the table of data (default is last observation of the file). This option may be used to read only part of the file, which may be useful for testing.
HTML Examples
sym01.import 01"c:\data.html"
loads into the SYM01 matrix object the data located in the HTML file “Data.HTML” located on the C:\ drive
Text and Binary Files
The syntax for reading text or binary files is:
sym_name.import(type=arg) source_description [table_description] [variables_description]
If a table_description is not provided, EViews will attempt to read the file as a free-format text file. The following table_description elements may be used when reading a text or binary file:
• “ftype = [ascii|binary]” specifies whether numbers and dates in the file are stored in a human readable text (ASCII), or machine readable (Binary) form.
• “rectype = [crlf|fixed|streamed]” describes the record structure of the file:
“crlf”, each row in the output table is formed using a fixed number of lines from the file (where lines are separated by carriage return/line feed sequences). This is the default setting.
“fixed”, each row in the output table is formed using a fixed number of characters from the file (specified in “reclen= arg”). This setting is typically used for files that contain no line breaks.
“streamed”, each row in the output table is formed by reading a fixed number of fields, skipping across lines if necessary. This option is typically used for files that contain line breaks, but where the line breaks are not relevant to how rows from the data should be formed.
• “reclines =int”, number of lines to use in forming each row when “rectype=crlf” (default is 1).
• “reclen=int”, number of bytes to use in forming each row when “rectype=fixed”.
• “recfields=int”, number of fields to use in forming each row when “rectype=streamed”.
• “skip=int”, number of lines (if rectype is “crlf”) or bytes (if rectype is not “crlf”) to discard from the top of the file.
• “comment=string“, where string is a double-quoted string, specifies one or more characters to treat as a comment indicator. When a comment indicator is found, everything on the line to the right of where the comment indicator starts is ignored.
• “emptylines=[keep|drop]”, specifies whether empty lines should be ignored (“drop”), or treated as valid lines (“keep”) containing missing values. The default is to ignore empty lines.
• “tabwidth=int”, specifies the number of characters between tab stops when tabs are being replaced by spaces (default=8). Note that tabs are automatically replaced by spaces whenever they are not being treated as a field delimiter.
• “fieldtype=[delim|fixed|streamed|undivided]”, specifies the structure of fields within a record:
“Delim”, fields are separated by one or more delimiter characters
“Fixed”, each field is a fixed number of characters
“Streamed”, fields are read from left to right, with each field starting immediately after the previous field ends.
“Undivided”, read entire record as a single series.
• “quotes=[single|double|both|none]”, specifies the character used for quoting fields, where “single” is the apostrophe, “double” is the double quote character, and “both” means that either single or double quotes are allowed (default is “both”). Characters contained within quotes are never treated as delimiters.
• “singlequote“, same as “quotes = single”.
• “delim=[comma|tab|space|dblspace|white|dblwhite]”, specifies the character(s) to treat as a delimiter. “White” means that either a tab or a space is a valid delimiter. You may also use the abbreviation “d=” in place of “delim=”.
• “custom="arg1"”, specifies custom delimiter characters in the double quoted string. Use the character “t” for tab, “s” for space and “a” for any character.
• “mult=[on|off]”, to treat multiple delimiters as one. Default value is “on” if “delim” is “space”, “dblspace”, “white”, or “dblwhite”, and “off” otherwise.
• “endian = [big|little]”, selects the endianness of numeric fields contained in binary files.
• “string = [nullterm|nullpad|spacepad]”, specifies how strings are stored in binary files. If “nullterm”, strings shorter than the field width are terminated with a single zero character. If “nullpad”, strings shorter than the field width are followed by extra zero characters up to the field width. If “spacepad”, strings shorter than the field width are followed by extra space characters up to the field width.
• “byrow”, transpose the incoming data. This option allows you to import files where the series are contained in rows (one row per series) rather than columns.
• “lastcol”, include implied last column. For lines that end with a delimiter, this option adds an additional column.
When importing a CSV file, lines which have the delimiter as the last character (for example: ‘name,description,date,’), EViews normally determines the line to have 3 columns. With the above option, EViews will determine the line to have 4 columns. Note this is not the same as a line containing ‘name,description,date’. In this case, EViews will always determine the line to have 3 columns regardless if the option is set.
A central component of the table_description element is the format statement. You may specify the data format using the following table descriptors:
• Fortran Format:
fformat=([n1]Type[Width][.Precision], [n2]Type[Width][.Precision], ...)
where Type specifies the underlying data type, and may be one of the following,
I - integer
F - fixed precision
E - scientific
A - alphanumeric
X - skip
and n1, n2, ... are the number of times to read using the descriptor (default=1). More complicated Fortran compatible variations on this format are possible.
• Column Range Format:
rformat="[n1]Type[Width][.Precision], [n2]Type[Width][.Precision], ...)"
where optional type is “$” for string or “#” for number, and n1, n2, n3, n4, etc. are the range of columns containing the data.
• C printf/scanf Format:
cformat="fmt"
where fmt follows standard C language (printf/scanf) format rules.
The optional variables_description may be formed using the elements:
• “colhead=int”, number of table rows to be treated as column headers.
• “types=("arg1","arg2",…)”, user specified data types of the series. If types are provided they will override the types automatically detected by EViews. You may use any of the following format keywords: “a” (character data), “f” (numeric data), “d” (dates), or “w” (EViews automatic detection). This option is rarely used.
• “na="arg1"”, text used to represent observations that are missing from the file. The text should be enclosed on double quotes.
• “scan=[int|all]”, number of rows of the table to scan during automatic format detection (“scan=all” scans the entire file). Note: If a "range=" argument is not specified, then EViews will only scan the first five rows of data to try and determine the data format for each column. Likewise, if the "na=" argument is not specified, EViews will also try to determine possible NA values by looking for repeated values in the same rows. If the first five rows are not enough to correctly determine the data format, use the "scan=" argument to instruct EViews to look at more rows. In addition, you may want to specify a the "na=" value to override any dynamic NA value that EViews may determine on its own.
• “firstobs=int”, first observation to be imported from the table of data (default is 1). This option may be used to start reading rows from partway through the table.
• “lastobs = int”, last observation to be read from the table of data (default is last observation of the file). This option may be used to read only part of the file, which may be useful for testing.
Text and Binary File Examples (.txt, .csv, etc.)
sym2.import c:\data.csv skip=5
reads “Data.CSV” into SYM2, skipping the first 5 rows.
sym01.import(type=text) c:\date.txt delim=comma
loads the comma delimited data “Date.TXT” into the SYM01 matrix object.
Cross-references
Display or change the label view of the symmetric matrix object, including the last modified date and display name (if any).
As a procedure, label changes the fields in the symmetric matrix object label.
Syntax
sym_name.label
sym_name.label(options) [text]
Options
The first version of the command displays the label view of the symmetric matrix. The second version may be used to modify the label. Specify one of the following options along with optional text. If there is no text provided, the specified field will be cleared.
c | Clears all text fields in the label. |
d | Sets the description field to text. |
s | Sets the source field to text. |
u | Sets the units field to text. |
r | Appends text to the remarks field as an additional line. |
p | Print the label view. |
Examples
The following lines replace the remarks field of SYM1 with “Data from CPS 1988 March File”:
sym1.label(r)
sym1.label(r) Data from CPS 1988 March File
To append additional remarks to SYM1, and then to print the label view:
sym1.label(r) Log of hourly wage
sym1.label(p)
To clear and then set the units field, use:
sym1.label(u) Millions of bushels
Cross-references
See
“Labeling Objects” for a discussion of labels.
Push updates to OLE linked objects in open applications.
Syntax
sym_name.olepush
Cross-references
See
“Object Linking and Embedding (OLE)” for a discussion of using OLE with EViews.
Import data from a foreign disk file into a symmetric matrix.
(This is a deprecated method of importing into a sym. See
Sym::import for the currently supported method.)
May be used to import data into an existing workfile from a text, Excel, or Lotus file on disk.
Syntax
matrix_name.read(options) [path\]file_name
You must supply the name of the source file. If you do not include the optional path specification, EViews will look for the file in the default directory. Path specifications may point to local or network drives. If the path specification contains a space, you may enclose the entire expression in double quotation marks.
Options
prompt | Force the dialog to appear from within a program. |
File type options
t=dat, txt | ASCII (plain text) files. |
t=wk1, wk3 | Lotus spreadsheet files. |
t=xls | Excel spreadsheet files. |
If you do not specify the “t” option, EViews uses the file name extension to determine the file type. If you specify the “t” option, the file name extension will not be used to determine the file type.
Options for ASCII text files
t | Read data organized by column (transposed). Default is to read by row. |
na=text | Specify text for NAs. Default is “NA”. |
d=t | Treat tab as delimiter (note: you may specify multiple delimiter options). The default is “d=c” only. |
d=c | Treat comma as delimiter. |
d=s | Treat space as delimiter. |
d=a | Treat alpha numeric characters as delimiter. |
custom = symbol | Specify symbol/character to treat as delimiter. |
mult | Treat multiple delimiters as one. |
rect (default) / norect | [Treat / Do not treat] file layout as rectangular. |
skipcol = integer | Number of columns to skip. Must be used with the “rect” option. |
skiprow = integer | Number of rows to skip. Must be used with the “rect” option. |
comment= symbol | Specify character/symbol to treat as comment sign. Everything to the right of the comment sign is ignored. Must be used with the “rect” option. |
singlequote | Strings are in single quotes, not double quotes. |
dropstrings | Do not treat strings as NA; simply drop them. |
negparen | Treat numbers in parentheses as negative numbers. |
allowcomma | Allow commas in numbers (note that using commas as a delimiter takes precedence over this option). |
Options for spreadsheet (Lotus, Excel) files
t | Read data organized by column (transposed). Default is to read by row. |
letter_number (default=“b2”) | Coordinate of the upper-left cell containing data. |
s=sheet_name | Sheet name for Excel 5–8 Workbooks. |
Examples
m1.read(t=dat,na=.) a:\mydat.raw
reads data into matrix M1 from an ASCII file MYDAT.RAW in the A: drive. The data in the file are listed by row, and the missing value NA is coded as a “.” (dot or period).
m1.read(t,a2,s=sheet3) cps88.xls
reads data into matrix M1 from an Excel file CPS88 in the default directory. The data are organized by column (transposed), the upper left data cell is A2, and the data is read from a sheet named SHEET3.
m2.read(a2, s=sheet2) "\\network\dr 1\cps91.xls"
reads the Excel file CPS91 into matrix M2 from the network drive specified in the path.
Cross-references
See
“Importing Data” for a discussion and examples of importing data from external files.
Resize the sym object.
Syntax
sym_name.resize rows/cols
Examples
sym1.resize 20
resizes the sym SYM1 to 20 rows/columns, retaining the contents of any existing elements and initializing new elements to 0.
Set the object attribute.
Syntax
sym_name.setattr(attr) attr_value
Sets the attribute attr to attr_value. Note that quoting the arguments may be required. Once added to an object, the attribute may be extracted using the @attr data member.
Examples
a.setattr(revised) never
String s = a.@attr("revised")
sets the “revised” attribute in the object A to the string “never”, and extracts the attribute into the string object S.
Cross-references
Set the column labels in a sym object.
Syntax
sym_name.setcollabels label1 label2 label3....
Follow the setcollabels command with a space delimited list of column labels. Note that each column label should not contain spaces unless it is enclosed in quotes. If you provide fewer labels than there are columns, EViews will keep the corresponding default column names (“C11”, “C12”, etc...).
Examples
sym1.setcollabels USA UK FRANCE
sets the column label for the first column in symmetric matrix SYM1 to USA, the second to UK, and the third to FRANCE.
Cross-references
Set the display format for cells in a symmetric matrix object spreadsheet view.
Syntax
matrix_name.setformat format_arg
where format_arg is a set of arguments used to specify format settings. If necessary, you should enclose the format_arg in double quotes.
For symmetric matrices, setformat operates on all of the cells in the matrix.
To format numeric values, you should use one of the following format specifications:
g[.precision] | significant digits |
f[.precision] | fixed decimal places |
c[.precision] | fixed characters |
e[.precision] | scientific/float |
p[.precision] | percentage |
r[.precision] | fraction |
To specify a format that groups digits into thousands using a comma separator, place a “t” after the format character. For example, to obtain a fixed number of decimal places with commas used to separate thousands, use “ft[.precision]”.
To use the period character to separate thousands and commas to denote decimal places, use “..” (two periods) when specifying the precision. For example, to obtain a fixed number of characters with a period used to separate thousands, use “ct[..precision]”.
If you wish to display negative numbers surrounded by parentheses (i.e., display the number -37.2 as “(37.2)”), you should enclose the format string in “()” (e.g., “f(.8)”).
Examples
To set the format for all cells in the symmetric matrix to fixed 5-digit precision, simply provide the format specification:
m1.setformat f.5
Other format specifications include:
m1.setformat f(.7)
m1.setformat e.5
Cross-references
See
Sym::setwidth,
Sym::setindent and
Sym::setjust for details on setting spreadsheet widths, indentation and justification.
Set the display indentation for cells in a symmetric matrix object spreadsheet view.
Syntax
matrix_name.setindent indent_arg
where indent_arg is an indent value specified in 1/5 of a width unit. The width unit is computed from representative characters in the default font for the current spreadsheet (the EViews spreadsheet default font at the time the spreadsheet was created), and corresponds roughly to a single character. Indentation is only relevant for non-center justified cells.
The default indentation setttings are taken from the Global Defaults for spreadsheet views (
“Spreadsheet Data Display”) at the time the spreadsheet was created.
For symmetric matrices, setindent operates on all of the cells in the matrix.
Examples
To set the indentation for all the cells in a symmetric matrix object:
m1.setindent 2
Cross-references
See
Sym::setwidth and
Sym::setjust for details on setting spreadsheet widths and justification.
Set the horizontal justification for all cells in the spreadsheet view of the sym object.
Syntax
sym_name.setjust format_arg
where
format_arg may be set to left, center, right, or auto (strings are left-justified and numbers are right-justified). Default display settings can be set in General Options; see
“Spreadsheet Data Display”.
Examples
sym1.setjust left
left-justifies the cells in the spreadsheet view of the sym SYM1.
Cross-references
See
Sym::setwidth and
Sym::setindent for details on setting spreadsheet widths and indentation.
Set the row labels in a sym object.
Syntax
sym_name.setrowlabels label1 label2 label3....
Follow the setrowlabels command with a space delimited list of row labels. Note that each row label should not contain spaces unless it is enclosed in quotes. If you provide fewer labels than there are rows, EViews will use the corresponding default row names (“R11”, “R12”, etc...).
Examples
sym1.setrowlabels USA UK FRANCE
sets the row label for the first row in sym SYM1 to USA, the second to UK, and the third to FRANCE.
Cross-references
Set the column width for all columns in a symmetric matrix object spreadsheet.
Syntax
matrix_name.setwidth width_arg
where width_arg specifies the width unit value. The width unit is computed from representative characters in the default font for the current spreadsheet (the EViews spreadsheet default font at the time the spreadsheet was created), and corresponds roughly to a single character. width_arg values may be non-integer values with resolution up to 1/10 of a width unit.
Examples
mat1.setwidth 12
sets the width of all columns in symmetric matrix MAT1 to 12 width units.
Cross-references
See
Sym::setindent and
Sym::setjust for details on setting spreadsheet indentation and justification.
Spreadsheet view of a symmetric matrix object.
Syntax
matrix_name.sheet(options)
Options
p | Print the spreadsheet view. |
Examples
m1.sheet(p)
displays and prints the spreadsheet view of symmetric matrix M1.
Displays the custom row and column labels of a sym spreadsheet.
Syntax
sym_name.showlabels mode
where mode is either 0 or 1 where 0 displays the default row and column labels and 1 displays the custom row and column labels (if present).
Examples
s1.showlabels 1
displays the custom row and column labels for the S1 spreadsheet. If custom labels have not been set the default labels will be displayed.
s1.showlabels 0
displays the default row and column labels for the S1 spreadsheet.
Cross-references
Descriptive statistics.
Computes and displays a table of means, medians, maximum and minimum values, standard deviations, and other descriptive statistics of each column in the symmetric matrix.
Syntax
matrix_name.stats(options)
Options
Examples
mat1.stats
displays the descriptive statistics view of symmetric matrix MAT1.
Cross-references
See
“Descriptive Statistics & Tests” and
“Descriptive Statistics” for a discussion of the descriptive statistics views.
Declare a symmetric matrix object.
The sym command declares and optionally initializes a matrix object.
Syntax
sym(n) sym_name[=assignment]
sym takes an optional argument n specifying the row and column dimension of the matrix and is followed by the name you wish to give the matrix.
You may also include an assignment in the sym command. The sym will be resized, if necessary. Once declared, symmetric matrices may be resized by repeating the sym command for a given matrix name.
Examples
sym mom
declares a symmetric matrix named MOM with one zero element.
sym y=@inner(x)
declares a symmetric matrix Y and assigns to it the inner product of the matrix X.
Cross-references
See
“Matrix Language” for a discussion of matrix objects in EViews.
Write EViews data to a text (ASCII), Excel, or Lotus file on disk.
Creates a foreign format disk file containing EViews data. May be used to export EViews data to another program.
This routine should realistically only be used in the oft-hand chance that you wish to write into a Lotus file. Improved Excel, text, and other format writing is available in
Sym::export.
Syntax
matrix_name.write(options) [path\filename]
Follow the name of the matrix object by a period, the keyword, and the name for the output file. The optional path name may be on the local machine, or may point to a network drive. If the path name contains spaces, enclose the entire expression in double quotation marks. The entire matrix will be exported.
Note that EViews cannot, at present, write into an existing file. The file that you select will, if it exists, be replaced.
Options
prompt | Force the dialog to appear from within a program. |
Other options are used to specify the format of the output file.
File type
t=dat, txt | ASCII (plain text) files. |
t=wk1, wk3 | Lotus spreadsheet files. |
t=xls | Excel spreadsheet files. |
If you omit the “t=” option, EViews will determine the type based on the file extension. Unrecognized extensions will be treated as ASCII files. For Lotus and Excel spreadsheet files specified without the “t=” option, EViews will automatically append the appropriate extension if it is not otherwise specified.
ASCII text files
na=string | Specify text string for NAs. Default is “NA”. |
d=arg | Specify delimiter (default is tab): “s” (space), “c” (comma). |
t | Write by column (transpose the data). Default is to write by row. |
Spreadsheet (Lotus, Excel) files
letter_number | Coordinate of the upper-left cell containing data. |
t | Write by column (transpose the data). Default is to write by row. |
Examples
m1.write(t=txt,na=.) a:\dat1.csv
writes the symmetric matrix M1 into an ASCII file named DAT1.CSV on the A: drive. NAs are coded as “.” (dot).
m1.write(t=txt,na=.) dat1.csv
writes the same file in the default directory.
m1.write(t=xls) "\\network\drive a\results"
saves the contents of M1 in an Excel file “Results.xls” in the specified directory.
Cross-references