RATS 10.1
RATS 10.1

<Root level>

Dealing with Data

Home Page

← Previous Next →

Almost every time that you use RATS, you will need to bring data into the program. Since collecting and organizing your data set may be the single most time-consuming part of your analysis, you would obviously like RATS to accept your data with as little fuss as possible. We have provided you with a wide range of options for handling this important step.

 

You should note that RATS is not a “data set-oriented” program. Simply selecting a data file does not make the contents immediately available for analysis: you must use the DATA instruction or a Data Wizard to bring the data into working memory. This may seem to be an unnecessary extra step, but it offers numerous advantages. For example, you have the option of reading in only certain series and certain entries from the data set. Converting data from one frequency to another can be handled automatically as you read in the data.

 

RATS supports reading and writing data from a wide range of sources and in many different formats. The most popular are RATS format and Excel spreadsheets. The Professional version of RATS supports SQL commands and ODBC connections for reading many types of databases.

 

The Tools

Below, we discuss the instructions you can use to read data from a file into a RATS session and to write data from RATS out to a file. If you are new to RATS, please see the tutorial in "Getting Started", particularly starting with "Example Three".

 

Getting Data In: The DATA Instruction and Data Wizards

Most of your projects in RATS will require reading data in from a file or files. The critical instruction for this is DATA, which reads data from a file into one or more series variables stored in memory.

 

You can write out the appropriate OPEN DATA and DATA instructions directly, or you can use one of the Data Wizards (on the Data/Graphics menu) to generate the necessary instructions.

 

The FORMAT option on DATA tells RATS what type of file you will be reading. Depending on the type of file, you may also need to use the ORGANIZATION option to specify whether the data series on the file are arranged in rows or columns. Note that the default format option for reading data is simple free-format text. RATS does not attempt to determine the format of the data file itself based on the filename extension—you need to set the FORMAT option yourself. 

 

Getting Data Out: The COPY Instruction and File–Export...

The companion instructions to OPEN DATA and DATA are OPEN COPY and COPY, which write data series to a file. COPY can produce data files in a wide range of formats, including spreadsheets, RATS format files, text files, and binary files. If you prefer to use menu operations to write the data, you can:

1.Use View—Series Window to list the series available in memory.

2.Select (highlight) the series you want to write to a file from that list.

3.Do File—Export..., select the desired file format from the drop-down list, enter a name for the file, and click OK.

 

Supported Formats

We list the formats in "Data Formats", divided into three broad categories with detailed information on each format (indicating where it can be used and any special details).

 

Other Instructions for Reading and Writing Data

DATA and COPY can only read and write SERIES type variables. For other types of variables (such as scalar reals, integers, arrays, labels, strings), you can use the INPUT or READ instructions to read data into RATS, and the WRITE or DISPLAY instructions to write data to a file. The REPORT instruction can be useful for creating specialized reports of data and statistics, similar to those created by RATS instructions like LINREG or STATISTICS.

 

Moving Data Around

RATS allows you to write data in a wide range of forms using COPY.

 

The RATS file format is directly portable across different platforms (Mac, Windows, UNIX) with no translation required. XLS, XLSX, WKS, PRN, DBF, DTA, DIF and the RATS Portable format are some other machine-independent formats which RATS supports.

 

Double-Check Your Data!

It is very important to be sure that data are being read in properly, particularly when reading from a data file for the first time. The tutorial in Example Three includes a number of suggestions for doing this, particularly using quick views of the sample statistics. In a RATS program file, you can use the TABLE instruction immediately after the DATA instruction(s) to get the same type of quick statistics table.

 

Series Labels on the Files

The advantage of the Time Series Databases and the Labeled Tables is that they have series labels already on the file, so you can pick and choose which series you want. If the name on the source is either not directly usable as a RATS variable (for instance, it includes spaces) or is too cryptic to be useful (the commercial databases need naming conventions to distinguish thousands of series), you can redirect the source name to a RATS name with a field

myseriesname<<"fileseriesname". For instance

 

cal(m) 1990:1

data(format=fred) / cudur<<"CAPUTLGMFDS" cunondur<<"CAPUTLGMFNS"

 

reads the current information for capacity utilization for durable and for non-durable manufacturing from FRED and maps them to shorter names for use in RATS.

 


Copyright © 2025 Thomas A. Doan