RATS 11.1
RATS 11.1

One of the advantages of using RATS is that you can do all the calculations within the program, allowing you to reproduce results exactly, and eliminating the error-prone transfer of numbers from computer output to paper or a calculator. By using the instruction REPORT, you can take this a step farther and create full tables ready, or nearly ready, to be copied directly into a word processor. This again has the advantage of allowing you to avoid typing numbers.
 

You can do much of what REPORT can do by an ingenious use of the DISPLAY instruction, but REPORT is better designed to create the types of tables commonly used in reporting statistical results.


Much of the output generated by RATS itself, including tables of regression and estimation results, are also saved automatically as REPORT objects, which you can access (and then copy-and-paste or export) using the Window menu.
 

Displaying and Recalling Reports

Every report you create using REPORT, or by using a WINDOW option on instructions like PRINT, is stored internally and can be redisplayed in a window using the Window>Report Windows operation. Reports generated automatically by RATS, such as the tables of results produced by many instructions, are also accessible this way. Many of those instructions offer TITLE options for labelling output, and RATS will use any title you supply as the name for the report in the Report Windows list.

Exporting Reports

You can get information from a report into a file or another program in several ways:

For reports you create using the REPORT instruction, you can use the UNIT and FORMAT options along with the ACTION=SHOW option to write the results directly to a file in any of several formats, including Excel, TeX, and HTML.

You can use Edit>Copy to copy the report and paste it into another application. (Report Windows also have Edit>Copy as TeX which copies a TeX table into the clipboard). If you copy from a Report Window into a spreadsheet program, RATS will copy data at full numeric precision. Otherwise, (for text or TeX), the data will be copied as it appears on the screen in RATS. REPORT allows you to control the number of decimals used in the output.

For a report displayed in a Report Window, you can use File>Export... to export the report to a file, with the same choices of format.

 

The last two are also available for any of the output that RATS itself generates. As noted above, just use Window>Report Windows to display the desired report, and then either copy and paste or use File>Export... to get the information out.

Saving Reports

In addition to exporting in a format readable to other software, you can also save a RATS Report in the RATS internal file format and re-open to display as a Report window. Or you can add a Report to a RATS Project either by adding a window that is on display (using Project>Add a Window) or an already saved file (Project>Add a File). The extension for a RATS Report is RRFZ (RATS Report Format Zip). The File>Open operation includes a format choice of "Report Files(*.rrfz)" to allow you open a saved file.

 


Using REPORT

A report is designed as a table anchored at row 1 and column 1. This is similar to a spreadsheet, except both rows and columns are numbered, rather than columns being lettered. And, like a spreadsheet, it’s effectively unlimited in size in each direction. You fill in entries by specifying the row and column at which information is to be placed. This can be done in whatever order you find convenient.

 

You will need to use at least three REPORT instructions to create a report:

1.REPORT(ACTION=DEFINE) initializes the report.

2.REPORT(ACTION=MODIFY) adds information to the report. (You actually don’t need to indicate ACTION=MODIFY, since that’s the default).

3.REPORT(ACTION=SHOW) indicates that the report is done.

 

You can also use ACTION=FORMAT to format the numerical data, and ACTION=SORT to sort the data based on the values in one of the columns.

 

The USE=reportname option allows you to work with multiple reports. For example, this allows you to add information to two different reports inside a loop, and then display both after the loop is completed.

ACTION=DEFINE

There are two options you can use with ACTION=DEFINE: HLABELS defines header labels, and VLABELS defines row labels. Both are vectors of strings. While the header labels are considered separate from the data, the VLABELS are just the first column of data, and can be altered later by using ACTION=MODIFY on column one.

ACTION=MODIFY

ACTION=MODIFY fills one or more cells at a row and column position in the table that you indicate. There are several ways to control the row and column positioning; you choose each separately:

1.You can do it directly by using ATROW=row and ATCOL=column.

2.You can open a new row or column with ROW=NEW or COLUMN=NEW.

3.You can use the same row or column as the last REPORT instruction with ROW=CURRENT or COLUMN=CURRENT.

4.(For ROW only) You can use ROW=FIND with STRING=search string to look for a match in column one. If no match is found, a new row is opened.

 

Beginning at the specified position, the expressions on the REPORT instruction are evaluated and, by default, placed into the cell positions running across the row. If you instead want the information inserted running down a column, use the option FILLBY=COLUMNS. Data in a RECTANGULAR or SYMMETRIC array will be inserted both in rows and columns in the same order as they appear in the array itself.

 

You can also insert another (already completed) REPORT which will extend from the specified position for as many rows and columns as are included in the REPORT.

 

The following is a simple example of the use of REPORT: it runs autoregressions with lags 1 to 12, and displays a table showing the lag number in column one and the \(R^2\) in the second column.

 

report(action=define,hlabels=||"Lags","R^2"||)

do lags=1,12

   linreg(noprint) lgdp

   # constant lgdp{1 to lags}

   report(row=new,atcol=1) lags %rsquared

end do lags

report(action=show)

 

You can also add some commonly used tags to the cells using the SPECIAL option. The choices are PARENS, BRACKETS, ONESTAR, TWOSTAR and THREESTAR. PARENS encloses the cell in parentheses, as is often done for standard errors or t-statistics, while BRACKETS uses [ and ]. ONESTAR attaches a single *, TWOSTAR adds ** and THREESTAR adds ***. You can do custom tags (for use in TeX) with the PREFIX and SUFFIX options.

 

The ALIGN=LEFT/CENTER/RIGHT/DECIMAL option lets you set the justification of text strings. The SPAN and TOCOL options allow you to define cells that span columns.

ACTION=MODIFY,REGRESSION

With ACTION=MODIFY, there is a special option which is designed specifically to handle the typical types of reports generated from several regressions. This is the REGRESSION option. For example,
 

report(action=define)

linreg foodcons

# constant prretail dispinc trend

report(regression)

linreg foodcons

# constant prretail dispinc{0 1}

report(regression)

report(action=show)

 

This produces the output shown below:

 

Constant      105.093801     90.277042

              (5.687192)    (6.085338)

PRRETAIL       -0.325062     -0.149396

              (0.071043)    (0.067939)

DISPINC         0.315237      0.199063

              (0.032067)    (0.044460)

TREND          -0.224430

              (0.061217)

DISPINC{1}                    0.063716

                            (0.051319)

 

You use this after running a regression. It adds a new column and inserts the coefficients and (by default) the standard error for each of the regressors into it. The default behavior is shown above: it searches the first column for a match with each of the explanatory variables. If a match is found, the information is put into that row. If there is no match, it adds a new row and puts the regressor’s label in it, so that if a future regression includes that regressor as well, REPORT will find it and put the coefficient from the new regression in that row. Here, both regressions have Constant, PRRETAIL and DISPINC. The first includes TREND but not DISPINC{1}, and the second DISPINC{1} but not TREND.

 

If you’d rather have the table arranged so that the regressors in the same position within the regression are to be considered “parallel”, you can add the option ARRANGE=POSITION. With that, you also need the ATROW option to fix the row for the first regressor. This is necessary because you might very well want to include some summary statistics in addition to the regression coefficients, and those should go at the top to allow room for the table to grow at the bottom.

 

Your choices for the extra information to be included with the coefficient are specified with the EXTRA option. The default for that is EXTRA=STDERRS. You can also choose TSTATS, BOTH and NEITHER. If you choose BOTH, each regressor will get three lines in the table, while if EXTRA=NONE, each will get just one.


 

ACTION=FORMAT

This sets the numerical format for a selected set of cells in the table. You can either set a specific format using a picture code supplied via the PICTURE option, or set a column width with the WIDTH option and letting REPORT figure out the best format to display the covered data in the width you choose.

 

By default, this applies to the entire table; to format only a subset of the entries, use the options ATROW and TOROW to fix the row range and ATCOL and TOCOL to set the column range. If you do ATROW without a TOROW, the range will be all rows from the set row on, and similarly for ATCOL without TOCOL.

 

For instance, in the last example, if we just wanted three digits right of the decimal, we would insert the instruction

 

report(action=format,picture="*.###")

 

after the regressions, but before the ACTION=SHOW. Note that this only affects the formatting used in displaying data. The data themselves are maintained at full precision.

 

You can also use the TAG and SPECIAL options to flag the maximum or minimum values with stars or parentheses, and the ALIGN=DECIMAL option to decimal-align the values.


 

ACTION=SORT

Use ACTION=SORT with BYCOL=column number to sort the report based on the values in the specified column. You can use the ATROW and TOROW options to limit the sorting to a range of rows, rather than to the entire report.

 


ACTION=SHOW

REPORT(ACTION=SHOW) displays the constructed table. By default, the output will be directed to the output unit (usually the output window). You can also display the report in a separate spreadsheet-style report window by including the option WINDOW=title of window.

Examples

This makes some improvements on the two regression example from before. It includes the \({R^2}\) and Durbin-Watson for each regression, formats the numbers to three decimal places, and displays the output in a window.

 

Note that the \({R^2}\) and Durbin-Watson values are added after the command REPORT(REGRESSORS). This is done because REPORT(REGRESSORS) adds a column, so by doing that first, you can just use COLUMN=CURRENT to place the summary statistics.
 

report(action=define)

report(atrow=1,atcol=1) "R^2"

report(atrow=2,atcol=1) "DW"


 

linreg foodcons

# constant prretail dispinc trend

report(regressors)

report(atrow=1,column=current) %rsquared

report(atrow=2,column=current) %durbin


 

linreg foodcons

# constant prretail dispinc{0 1}

report(regressors)

report(atrow=1,column=current) %rsquared

report(atrow=2,column=current) %durbin

report(action=format,picture="*.###")

report(action=show,window="FOODCONS Regressions")

report(action=show)


 

The next example reproduces Table 9.1 from Greene (2012), which shows a regression with standard errors computed using four different formulas. The header labels are the five regressor labels. Note the empty label at the start of that, since the first column has the row labels. The first row has the sample means of three of the variables. The second has the coefficient, the third the OLS standard errors, the fourth the t-statistics. All of these are inserted easily because the %BETA, %STDERRS and %TSTATS vectors have the information for all five regressors. Standard errors are computed using three other methods, and each one gets added into a new row. Finally, each of the columns is given a separate format.


 

REPORT(action=define, $

 hlabels=||"","Constant","Age","OwnRent","Income","Incomesq"||)


 

linreg(smpl=posexp) avgexp

# constant age ownrent income incomesq

stats(noprint) age

compute agemean=%mean

stats(noprint) ownrent

compute ownmean=%mean

stats(noprint) income

compute incmean=%mean


 

REPORT(atcol=1,atrow=1) "Sample Mean" "" agemean ownmean incmean

REPORT(atcol=1,atrow=2) "Coefficient" %beta

REPORT(atcol=1,atrow=3) "Standard Error" %stderrs

REPORT(atcol=1,atrow=4) "t-ratio" %tstats


 

linreg(smpl=posexp,robusterrors) avgexp

# constant age ownrent income incomesq


 

REPORT(atcol=1,atrow=5) "White S.E." %stderrs


 

compute %xx=%xx*(float(%nobs)/%ndf)

linreg(create,lastreg,form=chisquared)


 

REPORT(atcol=1,atrow=6) "D. and M.(1)" %stderrs


 

linreg(smpl=posexp) avgexp / resids

# constant age ownrent income incomesq

prj(xvx=xvx)

set resdm = resids/sqrt(1-xvx)

mcov(lastreg) / resdm

compute %xx=%xx*%cmom*%xx

linreg(create,lastreg,form=chisquared)


 

REPORT(atcol=1,atrow=7) "D. and M.(2)" %stderrs


 

REPORT(action=format,atcol=2,picture="*.##")

REPORT(action=format,atcol=3,picture="*.####")

REPORT(action=format,atcol=4,picture="*.###")

REPORT(action=format,atcol=5,picture="*.###")

REPORT(action=format,atcol=6,picture="*.####")


 

REPORT(action=show,window="Table 9.1")

 


Copyright © 2026 Thomas A. Doan