Creating a data file from scratch

There are four ways to do this: (1) Use your favorite spreadsheet to establish the data file, save it in Comma Separated Values format if necessary, then use gretl's "Import" option. (2) Use gretl's built-in spreadsheet. (3) Select data series from a suitable database. (4) Use your favorite text editor or other software tools to create the data file independently.

Here are a few comments and details on these methods.

Using a separate spreadsheet

This may be a good choice if you're comfortable with a particular spreadsheet. If you take this option, please pay attention to the specification of what your spreadsheet should look like. gretl expects a file that has (a) valid variable names on the first row and (b) a rectangular block of data beneath. A valid variable name is of 8 characters maximum; starts with a letter; and contains nothing but letters, numbers and the underscore character, _. Optionally the first column may contain strings such as dates (8 characters maximum). Such a column should be headed "obs" or "date", or its first row cell may be left blank. There should be exactly one non-data row at the top of the file.

In the case of an import from CSV, the format described above must be respected exactly. In the case of an import from an Excel or Gnumeric worksheet you have slightly more freedom: you can select the starting row and column for the import, hence skipping any "extra" rows or columns. Within the area selected for importing, however, the above rules apply.

If you use a spreadsheet to prepare your data you are able to carry out various transformations of the "raw" data with ease (adding things up, taking percentages or whatever): note, however, that you can also do this sort of thing easily — perhaps more easily — within gretl, by using the tools under the "Data, Add variables" menu and/or "Variable, define new variable".

You may wish to establish a gretl data set piece by piece, by incremental importation of data from other sources. This is supported via the "File, Append data" menu items. gretl will check the new data for conformability with the existing data set and, if everything seems OK, will merge the data. You can add new variables in this way, provided the data frequency, starting observation and series length all match the existing data set. Or you can append new observations for data series that are already present; in this case the variable names must match up correctly. Note that by default (that is, if you choose "Open data" rather than "Append data"), opening a new data file closes the current one.

Using the built-in spreadsheet

Under gretl's "File, Create data set" menu you can choose the sort of data set you want to establish (e.g. quarterly time series, cross-sectional). You will then be prompted for starting and ending dates (or observation numbers) and the name of the first variable to add to the data set. After supplying this information you will be faced with a simple spreadsheet into which you can type data values. In the spreadsheet window, clicking the right mouse button will invoke a popup menu which enables you to add a new variable (column), to add an observation (append a row at the foot of the sheet), or to insert an observation at the selected point (move the data down and insert a blank row.)

Once you have entered data into the spreadsheet you import these into gretl's workspace using the spreadsheet's "Apply changes" button.

Please note that gretl's spreadsheet is quite basic and has no support for functions or formulas. Data transformations are done via the "Data" or "Variable" menus in the main gretl window.

Selecting from a database

Another alternative is to establish your data set by selecting variables from a database. gretl comes with a database of US macroeconomic time series and, as mentioned above, the program will reads RATS 4 databases.

Begin with gretl's "File, Browse databases" menu item. This has three forks: "gretl native", "RATS 4" and "on database server". You should be able to find the file bcih.bin in the file selector that opens if you choose the "gretl native" option — this file is supplied with the distribution.

You won't find anything under "RATS 4" unless you have purchased RATS data[1]. If you do possess RATS data you should go into gretl's "File, Preferences, General" dialog, select the Databases tab, and fill in the correct path to your RATS files.

If your computer is connected to the internet you should find several databases (at Wake Forest University) under "on database server". You can browse these remotely; you also have the option of installing them onto your own computer. The initial remote databases window has an item showing, for each file, whether it is already installed locally (and if so, if the local version is up to date with the version at Wake Forest).

Assuming you have managed to open a database you can import selected series into gretl's workspace by using the "Import" menu item in the database window (or via the popup menu that appears if you click the right mouse button).

Creating a data file independently

It is possible to create a gretl data file using a text editor or software tools such as awk, sed or perl. This may be a good choice if you have large amounts of data already in machine readable form. You will, of course, need to study the gretl data formats (XML format or "traditional" format) as described in Chapter 5.

Further note

gretl has no problem compacting data series of relatively high frequency (e.g. monthly) to a lower frequency (e.g. quarterly): this is done by averaging. But it has no way of converting lower frequency data to higher. Therefore if you want to import series of various different frequencies from a database into gretl you must start by importing a series of the lowest frequency you intend to use. This will initialize your gretl data set to the low frequency, and higher frequency data can be imported subsequently (they will be compacted automatically). If you start with a high frequency series you will not be able to import any series of lower frequency.

Notes

[1]

See www.estima.com