REPORT Instruction |
REPORT(action=define,other options)
REPORT(action=modify,regressors,other options)
REPORT(action=modify,other options)variables/expressions
REPORT(action=format,other options)
REPORT(action=show,other options)
REPORT is a flexible report generator, which allows you to insert information into a table, format it and display it, either as text, or as a spreadsheet-style window which can be copied into other applications or exported in a variety of formats. You use a set of at least three REPORT instructions to create the table: REPORT with ACTION=DEFINE initiates the report, ACTION=MODIFY adds information (you’ll usually have more than one of these) and ACTION=SHOW displays it. ACTION=FORMAT can be used to format the numbers and add other formatting information.
Parameters
variables/expressions |
With ACTION=MODIFY, this list of variables and expressions provides the information which is to be inserted into the report. |
Options
ACTION=DEFINE/[MODIFY]/SHOW/FORMAT/SORT
REPORT with ACTION=DEFINE option initiates the report. ACTION=MODIFY (which is the default, and so can be omitted) adds content to the report. ACTION=FORMAT, together with PICTURE and WIDTH, allows you to adjust the formatting. ACTION=SORT sorts the report on the values of one the columns. Finally, use REPORT with ACTION=SHOW to display the report.
USE=name of report
USE allows you to define a new report object (when used with ACTION=DEFINE), or work with an existing report object (when used with the other choices for the ACTION option: MODIFY, FORMAT, SHOW, and SORT). If you omit the USE option, RATS uses the default internal report.
The ACTION option is used on every REPORT instruction. The remaining options are described below, grouped by the ACTION choice with which you use them.
Options Used With ACTION=DEFINE
TITLE="title for report" ["User Report"]
This option allows you to supply your own descriptive title for the report. This is used to identify it in the Window—Restore Reports menu operation.
HLABELS=VECTOR of STRINGS to provide the column (header) labels
VLABELS=VECTOR of STRINGS to provide row labels
These provide labels for the columns and rows in the displayed report. Note: the HLABELS are outside the main body of the report, while the VLABELS are considered to be in column one.
Options Used With ACTION=MODIFY
REGRESS/[NOREGRESS]
EXTRA=[STDERRS]/TSTATS/BOTH/NEITHER
ARRANGE=[NAME]/POSITION
The REGRESS option adds the results of the most recent regression to the report. The coefficients are always included and, by default the standard errors are reported as well. You can use the EXTRA option to select t-statistics instead of, or in addition to the standard errors, or to include neither.
When adding results from multiple regressions to the same report, by default, the regressors will be arranged by name—if a regressor in the current regression also appeared in one of the previous regressions, the results for that regressor will be placed in the same row (in a new column) as the regressor with the matching name in the earlier regressor. If you’d rather have the table arranged so that the regressors in the same position within the regression are to be considered “parallel”, use the option ARRANGE=POSITION (you should also use the ATROW option to fix the row for the first regressor).
ROW=[INPUT]/NEW/CURRENT/FIND
COL=[INPUT]/NEW/CURRENT
STRING=search string
These determine the position at which new data is to be inserted. The defaults are ROW=INPUT and COL=INPUT. With those, the ATROW and ATCOL options give the position. NEW means that a new row or column is created. CURRENT means that the last row or column used will be used again. ROW=FIND, combined with the STRING option, looks for a match in the first column. If a match isn’t found, a new row is opened up.
ATROW=row number or starting row number [row 1]
ATCOL=column number or starting column number[column 1]
ATROW and ATCOL indicate an exact location to begin inserting the new data.
FILLBY=[ROWS]/COLUMNS
With the default choice FILLBY=ROWS, VECTORS and lists of scalars are added to the report going across in a row. Use FILLBY=COLUMNS if you instead want the data to be inserted running down a column. This option has no effect on data in RECTANGULAR or SYMMETRIC arrays, which are added across both rows and columns exactly as the data is stored in the array.
ALIGN=[LEFT]/CENTER/RIGHT/DECIMAL
Sets the alignment of a string or label. RIGHT and DECIMAL are the only ones you can use for numbers.
SPECIAL=[NONE]/ONESTAR/TWOSTARS/THREESTARS/PARENS/BRACKETS
You can use SPECIAL to enclose cells in parentheses (), brackets [] or tag them with one star (*), two stars (**) or three stars (***).
PREFIX="prefix formatting string" [not used]
SUFFIX="suffix formatting string" [not used]
These can be used as an alternative to the SPECIAL option if you need some other form of tagging (for eventual use in TeX). You can use these alone or together. For instance, SUFFIX="^{**}" will add ** as a superscript (ordinarily ** is on the same line at normal text size), and PREFIX="\lbrace",SUFFIX="\rbrace" will enclose the element in { }.
SPAN/[NOSPAN]
TOCOL=span up to and including this column [unused]
Use SPAN if you want the cell being added to be able to span multiple columns. This is normally used when inserting a text string that serves as a header for the next set of rows. With NOSPAN, the width of the column being used will be expanded as needed to fit the supplied information. Use TOCOL to span to a specific column.
Options Used With ACTION=FORMAT
PICTURE="picture code for formatting data"
WIDTH=maximum width for numerical display
These are used with ACTION=FORMAT. If you provide a picture code, you set the format yourself. If you use WIDTH, you see the maximum width in character positions, and REPORT determines a common format which will display all the data covered by the request within that width.
TAG=MAXIMUM/MINIMUM
SPECIAL=[NONE]/ONESTAR/TWOSTARS/THREESTARS/PARENS/BRACKETS
TAG identifies the maximum or minimum value in the range specified by the ATROW, TOROW, ATCOL and TOCOL options. The SPECIAL option determines how the cell will be identified: enclosed in parentheses or brackets, or tagged with one star (*), two stars (**) or three stars (***). For example, the following “stars” the maximum value in the first column:
report(act=format,atcol=1,tocol=1,tag=max,special=onestar)
ATROW=starting row number [1]
ATCOL=starting column number [l]
TOROW=ending row number [last row]
TOCOL=ending column number [last column]
These set the range of rows and columns over which the PICTURE and WIDTH formatting will be applied, or over which TAG will search to identify a maximum or minimum.
ALIGN=[LEFT]/CENTER/RIGHT/DECIMAL
Sets the alignment of a string or label. RIGHT and DECIMAL are the only ones you can use for numbers.
Options Used With ACTION=SORT
BYCOL=column number
This sorts the report by the values in the selected column.
ATROW=starting row number
TOROW=ending row number
You can use ATROW and TOROW to limit the sorting to a specific range of rows.
Options Used With ACTION=SHOW
WINDOW="title for window"
By default, the output will be displayed as text in the output window. Use the WINDOW option if you instead want to display the report in a new spreadsheet style “report window”, with the title you specify. From a report window, you can use File–Export to export the results to an external file in a variety of formats.
UNIT=COPY/[OUTPUT]/other unit
FORMAT=CSV/DBF/DIF/HTML/PRN/RTF/TEX/TSD/WKS/XLS/XLSX/XML [default is formatted text]
You can use the UNIT option to redirect the report output to another unit (usually an external file previously opened with an OPEN instruction). If you use UNIT without using FORMAT, RATS will generate a text file, with the output formatted just as it is when displayed in the output window. If you prefer, you can use the FORMAT option to select one of the other file formats, as shown above (FORMAT only applies when used in conjunction with UNIT).
Examples
Below is an excerpt from example 10.3 from Verbeek(2008). This uses the REGRESS option to build a report presenting the coefficients and standard errors from four different regressions (three panel data regressions and one OLS estimation).
*
* Define the report and provide column headers:
*
report(action=define,hlabels=||"Variable","Between",$
"Fixed Effects","OLS","Random Effects"||)
*
* Perform the regressions, following each with REPORT(REGRESS)
* to add the results to the report:
*
preg(method=between) wage
# constant school exper expersq union mar black hisp pub
report(regress)
preg(method=fixed) wage
# exper expersq union mar pub
report(regress)
linreg wage
# constant school exper expersq union mar black hisp pub
report(regress)
preg(method=random,vindiv=.1055,vrand=.1234) wage
# constant school exper expersq union mar black hisp pub
report(regress)
*
* Format the cells to use 3 decimals places and display the table:
*
report(action=format,picture="*.###")
report(action=show)
Here’s the resulting output:
Variable Between Fixed Effects OLS Random Effects
Constant 0.490 -0.034 -0.104
(0.078) (0.065) (0.111)
SCHOOL 0.095 0.099 0.101
(0.004) (0.005) (0.009)
EXPER -0.050 0.116 0.089 0.112
(0.018) (0.008) (0.010) (0.008)
EXPERSQ 0.005 -0.004 -0.003 -0.004
(0.001) (0.001) (0.001) (0.001)
UNION 0.274 0.081 0.180 0.106
(0.017) (0.019) (0.017) (0.018)
MAR 0.145 0.045 0.108 0.063
(0.014) (0.018) (0.016) (0.017)
BLACK -0.139 -0.144 -0.144
(0.017) (0.024) (0.048)
HISP 0.005 0.016 0.020
(0.015) (0.021) (0.043)
PUB -0.056 0.035 0.004 0.030
(0.038) (0.039) (0.037) (0.036)
The next set of code is from example 2.7 from Verbeek (2008):
cal(m) 1960:1
open data capm2.dat
data(format=prn,org=columns) 1960:1 2002:12 $
rfood rdur rcon rmrf rf jandum
*
* Define a report, and provide a set of row labels for the first column:
*
report(action=define)
report(atrow=1,fillby=cols) $
"Company" "Excess Returns" "" "Uncentered R^2" "s"
*
* Now do the first regression and add four numerical results to the report.
* COL=NEW puts these in a new column.
* ATROW=1 starts the information in row one.
* FILLBY adds items going down the column, rather than across in rows:
*
linreg rfood
# rmrf
report(col=new,atrow=1,fillby=cols,align=center) $
"Food" %beta(1) %stderrs(1) %trsq/%nobs sqrt(%seesq)
*
* Repeat process for two more regressions
*
linreg rdur
# rmrf
report(col=new,atrow=1,fillby=cols) $
"Durables" %beta(1) %stderrs(1) %trsq/%nobs sqrt(%seesq)
linreg rcon
# rmrf
report(col=new,atrow=1,fillby=cols) $
"Constuction" %beta(1) %stderrs(1) %trsq/%nobs sqrt(%seesq)
*
* Generate the report:
*
report(action=show)
And here is the output:
Company Food Durables Constuction
Excess Returns 0.790380 1.112622 1.156058
0.028397 0.028953 0.025148
Uncentered R^2 0.600674 0.741429 0.804054
s 2.902180 2.959008 2.570095
Copyright © 2025 Thomas A. Doan