RATS 10.1
RATS 10.1

Introduction to RATS /

Example One: The RATS Editor

Home Page

← Previous Next →

To introduce you to RATS, we will take you step-by-step through several sample RATS sessions. We’ll describe the key menu operations and RATS instructions, and give you a feel for using the program.

 

If you have not already installed RATS on your computer, see "Installing RATS" for installation instructions. See "Where to Find It" for Windows or Macintosh to see where the applications are located.

 

The RATS Editor

First, start the program in interactive mode. For Windows, open the WinRATS folder on the Start menu or desktop and click on the WinRATS icon. (The folder and icon will generally be a longer name which includes the current version number). For MacRATS, click on the MacRATS program icon. For UNIX, click on the “ratsx” file, or type ratsx at the command prompt.

 

This loads the RATS interactive interface, which we call the RATS Editor. You will see the RATS menu bar, the toolbar, and an empty worksheet window called noname00.txt. (If you don’t see this, select File—New—Editor/Text Window or use the <Ctrl>+N keystroke).

 

This environment allows you to type in and execute commands; use menu-driven wizards to perform tasks; save or print program files and output; export information to various types of files; display, save, and print graphs; and more.

 

If you look at the File and Edit menus, you’ll see familiar operations, like Save and Print on File, and Cut, Copy and Paste on Edit; and they all work as you would expect (short-cut keys as well). What you won’t find are operations for Bold, Italics, Centering, etc. The RATS editor isn’t intended to be used to produce a final document—its job is to help you process numerical information and get it into your final document as accurately as possible.

 

While you do have some choice of font, it’s from the very limited number of “monospaced” fonts (Courier is by far the most common of these). In a monospaced or typewriter font, all characters are the same width, making it easy to line up different types of output. RATS also produces output which is in specially formatted tables, but those are separate from the main editor window.

 

Input and Output Windows

RATS allows you to have multiple windows open at one time, but you can only execute instructions from the window that is designated as the Input Window. This window will have {i} appended to the window title, both on the window’s title bar, and on the window list in the Window menu.

Similarly, any output generated goes to the window designated as the Output Window, which will have {o} appended the name. This can be a separate window, or it can be the same as the Input Window. When you first start the program, the noname00.txt window should be set as both input and output, shown by {io} in the window title bar.

 

Executing Instructions

In this tutorial, much of the work is done using “point-and-click” operations with menus and dialog boxes. However, we will also show you how to type in and execute instructions directly, which is often the fastest way to accomplish many tasks once you have some familiarity with the language.

 

In general, you can execute an instruction by just typing it into the Input Window and hitting the <Enter> key. You can also execute a block of instructions by selecting (highlighting) the lines you want to execute using the mouse or the keyboard, and then hitting <Enter> or clicking on the “Run” icon . RATS will execute all of the instructions, in order, from top to bottom.

What Should You Type In?

We put large pointers () in the margin next to all the instructions (or groups of instructions) that we want you to enter and execute. We will also sometimes show you other sample uses of these instructions. Some of these will work with the sample data sets, but others will not. For now, we recommend that you only type in the instructions marked with a pointer.

 

The instructions we discuss in this section are provided on a file called ExampleOne.rpf (RPF stands for RATS Program File). If you encounter any difficulties, you can open that file (using File—Open) to see exactly how the instructions should look.

 

The DISPLAY Instruction

To get started, type the line below into the blank input window and then hit  the <Enter> key (which tells RATS to execute the line you just typed):

 

display "Hello, World"

 

RATS should display the text “Hello, World” on the next line (or to your output window if using separate input and output windows). As you can see, DISPLAY does just what its name implies—it displays information.

 

You can also use it to display the results of computations. For example, a popular econometrics textbook includes the following expression to compute “by hand” the least squares estimator for the intercept in a regression (Hill et al, 2008, page 22):

\begin{equation} b_1 = \bar y - b_2 \bar x = 283.5737 - \left( {10.2096} \right)\left( {19.6408} \right) = 83.4160 \label{eq:started_hillexample} \end{equation}

You can do this computation easily using DISPLAY. Try typing in the line below (with no spaces inside the expression), and hitting <Enter> to execute it. Note that you can use ? in place of using the DISPLAY instruction name:

 

?283.5737-10.2096*19.6048

 

RATS will do the computation and display the result:   83.41653

 

Note that the * symbol is the multiplication operator. The addition and subtraction operators are the usual + and - . Other operators include / for division and ^ for exponentiation. We describe the full set of operators in "Arithmetic Expressions". Multiplication is never implied, the way it is in the algebraic expression above, so you must use the * to multiply two terms.

 

Rounding and Using Full Precision

The textbook actually reports a slightly different result (83.4160). That’s because the numbers presented in the book for equation \eqref{eq:started_hillexample} (and used as input in our computation) were themselves rounded versions of the numbers actually used to produce the result shown in the book. RATS (and most other statistical software) does its calculations in “double precision”, which gives roughly fifteen significant digits. Now no practical data set records numbers to anything like that level of accuracy, so if the data going in are only good for four digits, it’s pointless to report results at fifteen digits. However, whenever possible you should keep all the intermediate calculations in full precision: in short, don’t round intermediate values. The software is already rounding at fifteen, which sometimes isn’t even enough for very poorly-behaved data.

 

DISPLAY picks the format itself, and usually errs on the side of too many digits. If you want this number rounded to four decimal places, you can use “picture codes”, which provide a template for numerical output. Insert the picture code before the number or expression. For example, edit your original instruction by inserting ##.#### (with space after) before the expression:

 

?##.#### 283.5737-10.2096*19.6048

 

Hit <Enter> to re-execute this line. The cursor can be anywhere in the line—it doesn’t have to be at the end of the line (you’re executing the line, not inserting a line break).

 

As we said before, the job of the RATS editor is to help you get information into your final document as accurately as possible. RATS comes with over 1000 examples out of major textbooks. The most common type of error in those textbooks comes from taking a number computed by the software and manually re-typing it (incorrectly) into the manuscript. If you want a value, let RATS do the rounding, and use copy and paste to get it into your document. Select the text you need, and do a copy operation. The text copy is so important, there are four ways to do it:

the keyboard shortcut (<Ctrl>+C)

the copy toolbar icon

the standard menu operation Edit—Copy

“Copy” on the contextual (right click) menu.

 

DISPLAY can also show more than one calculation, and more than one field (which is why we wanted you to be careful about spaces). For instance, you can edit your line to add a description and hit <Enter> to execute:

 

?"intercept=" ##.#### 283.5737-10.2096*19.6048

 

The COMPUTE Instruction

COMPUTE is another important instruction. If you need to do an algebraic calculation, but don’t need to see the result, you will probably do that using COMPUTE. An alternative to doing our computation with DISPLAY would be (execute both lines):

 

compute intercept = 283.5737-10.2096*19.6048

?"intercept=" ##.#### intercept

 

This does the calculation and saves the result into a new variable called INTERCEPT, and then displays that. Your screen should now look something like this:

 

 

It’s important to note a major difference between RATS and “math packages” like Gauss™ and MATLAB™. With either of those, the first “display” would be done with

 

283.5737-10.2096*19.6048;

 

(“display” is implicit since there is no other place for result), and the COMPUTE with

 

intercept=283.5737-10.2096*19.6048;

 

With math packages, the basic unit of input is an expression. With RATS, it’s an instruction. DISPLAY and COMPUTE are two examples—there are roughly 200 others, many of which do very sophisticated calculations requiring (internally) thousands of separate sub-calculations. Many of those have point-and-click “wizards” on the Data/Graphics, Statistics and Time Series menus to help you apply them to your data.

 

Learn More: Input and Output Windows

The Run/Stop Buttons

While RATS is executing instructions, the “Run” icon   changes to the “Stop” icon . “Run” returns as soon as the task is complete and RATS is ready to accept more instructions. In many cases, you won’t even notice this because it finishes so quickly. However, if you are doing something which does take a long time, and you decide that you don’t really want it to continue, you can click on “Stop” to interrupt the execution.

 

Editing Without Executing (Ready vs Local Mode)

Hitting the <Enter> key in the Input Window normally executes the current line. If you need to insert a line break without executing the line (perhaps you want to input several lines before executing them), do the following:

On Windows and UNIX/Linux systems, you can edit lines without executing them by putting RATS into “local” mode, either by clicking on the  (Ready/Local) button  or by hitting <Ctrl>+L. Clicking on the Ready/Local button (which will now look like ) again (or hitting <Ctrl>+L again) puts RATS back into “ready” mode. “Ready” means that RATS is ready to accept instructions for execution.

On a Macintosh, if you have a keyboard with separate <Return> and <Enter> keys, you can use <Return> to insert a line break  without executing a command. If not, use the same procedure as for Windows.

Configuring Input and Output Windows

You can switch the input or output functions to a particular editor window using the menu items Window–Use for Input and Window–Use for Output or the corresponding  and  toolbar icons. We tend to use the editor windows in one of two ways:

1.For quick work, we simply start up RATS and work with the noname window the way we just did in the example. If you aren’t really interested in developing a set of RATS instructions to execute later and just want some quick answers, this is the simplest setup.

2.To develop a new (or existing) program, we designate one window as the Input Window, and a second window as the Output Window. With input and output in separate windows, it is much easier to keep a copy of the instructions that we decide we like. The  and  toolbar icons provide easy ways to get this split-window setup—they automatically open a second window, designate it as the output window, and tile the two windows horizontally or vertically, respectively.

If you decide that you really like the second setup, you can set RATS to default to that on the "Editor" tab of the Preferences—set the “Open New Output Window at Start” box.


Copyright © 2025 Thomas A. Doan