Reading Data Into G7

G7 has seven commands related to introduction of ASCII data, in addition to speciallized routines for reading other format such as Excel spreadsheets. The seven are:

data:

introduces a single series prepared in G7’s data input format

matdat:

introduces one or more series in a column format usually found in spreadsheet programs

update:

adds new observations or revises observations in series already in a data bank

matup:

updates from column-format data

monup:

updates a quarterly series with monthly data

wrindex:

turns on or off the writing of the index file of the workspace

More detail on the commands is given below.

(da)ta <series_name>

Introduces data into the workspace data bank. There are 2 forms the command can take.

Form 1:

data sales
2010.1  34.0 56.8 44.5 55.6
2011.1  39.3 41.2 43.9 47.0;

The first number on each line is the date of the first observation on that line. Input is terminated by a “;”. The “;” may be omitted in an “add” file, except on the last line of the file.

Form 2:

data sales 2010.1
34.0 56.8 44.5 55.6
39.3 41.2 43.9 47.0;

The date of the first observation is given on the command line immediately after the series name. No dates appear on subsequent lines.

Form 1 is easiest if the data is being entered by hand. Form 2 is easier if the data is generated by a program.

Input data may contain floating point numbers in exponential form. Thus, the number 3 may be represented as 3.0, 3.0E+00, .300E+01, or 30E-01. Only E, not e, is recognized in this context. Any number of spaces between data observations is allowed (the data are free format).

A missing value may be represented by a single question mark (?). Therefore

data sales
2010.1 34.0 ? 44.5 55.6

indicates that the sales for 2010.2 quarter is missing.

(up)date <series_name>

Works like the data command (Form 1) but updates an existing series. The data following the command contain only the data points to be changed. The updated series is placed in the workspace only.

monup(mup) <series_name>

This is used for updating a quarterly series with monthly data.

Example:

mup rtb
   2010.3  9.120 9.390 9.050 8.710 8.710 8.960
   2011.1  8.930 9.030 9.440;

‘rtb’ is a quarterly series being updated with monthly data. 9.120 is the value of ‘rtb’ in July 2010; 9.390 is the value in August 2010, etc. Note that quarterly dates are the first numbers on each line and three monthly observations must be present for each quarter.

matdat [date]

Brings data into G7 prepared by a spreadsheet program. There are two major forms in which the series can be arranged. The series can be arranged either in vertical columns with the name of the series at the top of the column, or in horizontal rows with the names appear on the same line of the matdat command. Up to 20 columns of numbers occupying up to 160 characters per line may be given. The two forms of the command are:

Form 1:

matdat
           gnp     c       cd      cnd     cs
   81.1    1513    950     146     359     445
   81.2    1512    949     140     361     448
   81.3    1522    956     143     361     450;

where dates appear as the first number on each line. Here 1513 is the value of gnp in 1981.1, 1522 is the value in 1981.2, etc.

or

matdat 1981.1
   gnp     c       cd      cnd     cs
   1513    950     146     359     445
   1512    949     140     361     448
   1522    956     143     361     450;

The date of the first observation appears on the command line, and no dates appear on subsequent lines. Use a semicolon to end the data. (You must have a semi-colon on the last line of data for either form.)

Form 2:

matdat gnp out(1-4) 1981.1
   1513    1512     1522
   950     949      956
   359     140      143
   359     361      361
   445     448      450;

Here, series names are given immediately after matdat with starting date given as the last argument on the matdat line. The first series reads from the first line after the matdat, the second series reads from the second line, and so on. Note also that group definitions are allowed here.

matup [date]

Uses the same format as the matdat command, but updates series already in the bank.

To use the matdat or matup commands effectively, create an “add” file containing the data or matdat statements necessary to bring in the data. For example, to transfer data from a spreadsheet where the data already exist in columns, use the following steps.

Print the spreadsheet data to a file. (In LOTUS, you would print the data range to a file, creating a PRN file.) Add the necessary G7 data commands to the file just created using an the editor. (Alternatively, include the commands in the spreadsheet before you print the range.) If the column data do not include dates, use Form 2 of the matdat command.

From the G7 console, use the add command to bring in the data stored in the file created by STEP 1.

add filename_created_in_STEP_1

Speeding Processing of Long Data Files

When adding long data files to G7, two commands can accelerate considerably the processing of the data. Include these commands as part of your add file to introduce data, but only after you are sure the add file is trouble free.

(addt)ype n

Normally, G7 writes to the screen all of the input file when an add is underway. Turning screen writing off with this command speeds up the operation greatly.

Turn screen writing back on again at the end with

addt y
(wri)ndex <y | n>

Normally G7 writes the entire index file of the workspace as each variable is added. When many series are added, this feature lengthens processing time. To defer writing the index until the entire add file is processed, “wri n” turns off writing and “wri y” turns it on again and writes the index. A ‘q’ with writing off will cause the index to be written before quitting, so there is no danger of losing everything by forgetting “wri y”.