Command Reference : Command Reference
Insert contents into cell of a table.
The setcell command puts a string or number into a cell of a table.
setcell(table_name, r, c, content[, "options"])
Provide the following information in parentheses in the following order: the name of the table object, the row number, r, of the cell, the column number, c, of the cell, a number or string to put in the cell, and optionally, a justification and/or numerical format code. A string of text must be enclosed in double quotes.
The justification options are:
Center the text/number in the cell.
Right-justify the text/number in cell.
Left-justify the text/number in cell.
The numerical format code determines the format with which a number in a cell is displayed; cells containing strings will be unaffected. The format code can either be a positive integer, in which case it specifies the number of decimal places to be displayed after the decimal point, or a negative integer, in which case it specifies the total number of characters to be used to display the number. These two cases correspond to the Fixed decimal and Fixed character fields in the number format dialog.
Note that when using a negative format code, one character is always reserved at the start of a number to indicate its sign, and that if the number contains a decimal point, that will also be counted as a character. The remaining characters will be used to display digits. If the number is too large or too small to display in the available space, EViews will attempt to use scientific notation. If there is insufficient space for scientific notation (six characters or less), the cell will contain asterisks to indicate an error.
setcell(tab1, 2, 1, "Subtotal")
puts the string “Subtotal” in row 2, column 1 of the table object named TAB1.
setcell(tab1, 1, 1, "Price and cost", "r")
puts the a right-justify string “Price and cost” in row 1, column 1 of the table object named TAB1.
Note that in general, that unless you wish to control the formatting, assignment statements of the form
Mytable(1,1) = "hello"
are easier than using the default setcell statement:
“Working with Tables and Spreadsheets”describes table formatting using commands. See “Table Objects” for a discussion and examples of table formatting in EViews.
See also Table::setjust and Table::setformat. Note that this command is supported primarily for backward compatibility. There is a more extensive set of table procs for working with and customizing tables. See “Table Procs”.