Input of Vectors into Vam Files

vmatdata

The vmatdata command puts whole vectors into the default Vam file. It can be used to bring in data in a variety of formats commonly used by statistical agencies in releasing input-output tables. It can read a file that shows any one of the following:

  • one vector in columns for several years

  • one vector in rows for several years

  • several vectors in columns for one year

  • several vectors in rows for one year

The vmatdat command requires at least two lines and three if a format for reading is specified. The form of the first line is always the same, as is the form of the third line, if present. The second line has two different forms, one if several vectors are being read for one year and another if data for one vector is being read for several years. The form of the command is

vmatdat <r|c> <nv> <nyrs> <first> <last> [skip]
<year> <vec1> <vec2> … <vecnv>
vmatdat <r|c> <nv> <nyrs> <first> <last> [skip]
<vec> <year1> <year2> … <yearnyrs>
[form]

where
r|c:

is ‘r’ or ‘c’ according to whether the vectors are rows or columns.

nv:

is the number of vectors.

nyrs:

is the number of years.

first:

is the position in the vector in the Vam file of the first item in the data which follows.

last:

is the position in the vector in the Vam file of the last item in the data which follows.

skip:

is the number of characters on each line that should be skipped before beginning to read data. If no value for skip is provided, then a form line (explained below) will be expected as the third line. If no characters are to be skipped and no form line provided, then give skip a value of 0.

year:

is the year of the vectors or the first year if nyrs > 1.

vec1:

is the name of the first vector, “vec2” is the name of the second vector, etc.

form:

If no value for skip is given, then this form line must be provided. It should have the letter ‘r’ in every position that is to be read in the following table. This device allows direct reading of tables that have columns of data separated by ‘|’ or other symbols or that have subtotals that are not to be read.

A typical form line and a matching data line are

form:                  rrrrrrrrrrrrrrrrrrrrr          rrrrr     rrrr
data: Agriculture     | 3450  3718  249   0  | 6780|  8102 |**| 1598

Columns that do not have an ‘r’ simply are ignored. Consequently, they cannot be used to separate data fields. Thus, reading the following

rrrrrrrr       rrrr
     851       2971

would produce one number, 8512971, not two numbers, 851 and 2971.

The first version of the second line is used if there are several vectors for one year; the second is used when giving data for one vector in several years. In both cases, the item of which there is only one is specified first and then the items of which there are several.

Any line beginning with a ‘#’ is skipped completely.

For example, the lines

# Example of several vectors in columns for one year:
vmatdat c 6 1 1 57 3
1986 cons gov inv stk exp imp
1        21          0         2        -3           6           7
...     ...        ...       ...       ...         ...         ...
57       38        401         0         0          17          15

would read the 6 columns of data into positions 1 through 57 of the named vectors (cons, gov, …) for the year 1986. Positions 1 - 3 of each line, which contain the sector number for easy visual reference, are skipped.

Here is another example that reads the vectors as rows, as often may be the case when reading printed tables of primary inputs.

# Example of several vectors in rows for one year:
vmatdat  r 6 1 1 6 16
1986 labinc propinc deprec inter profit tax
#                  1     2     3     4     5     6
labor income    7303    21   368  1203  1302   820
proprietor inc  1215     9   100   107   303    92
depreciation     950     3    82   104   121    73
interest income  845     7    83    54    95    52
profits           50     3    25   217   337    38
indirect taxes   121     1    32   178   294    29

Note the use of the line beginning with a ‘#’ to provide labels for the columns. The second form of the second line is illustrated by the following example that reads one vector, cons, for five years.

# Example of a single vector in columns for several years:
vmatdat c 1 5  1 57 2
cons 1985 1986 1987 1988 1989 1990
 1   31.8 37.2 32.5 38.7 41.2 43.1
....
57   1.2  1.7  1.8  2.0  2.1  2.2

Finally, here is an example that reads a single vector in columns for several years.

# Example of reading a single vector in columns for many years.
vmatdat r 1 28 1 8  12
demog 1989 1990 1991 1992 1993 1994 1995 1996 1997
# Date  ncent south  west college  twoy  fs1   fs2   fs5   head1 head3
89.000  0.243 0.345 0.208  0.220  0.469 0.243 0.323 0.106  0.274 0.350
90.000  0.241 0.346 0.209  0.222  0.476 0.250 0.320 0.105  0.267 0.350
91.000  0.240 0.347 0.211  0.224  0.482 0.247 0.320 0.105  0.263 0.348
92.000  0.238 0.348 0.212  0.226  0.487 0.245 0.319 0.104  0.260 0.346
93.000  0.237 0.349 0.213  0.227  0.493 0.244 0.319 0.102  0.257 0.345
94.000  0.236 0.349 0.215  0.227  0.495 0.243 0.321 0.106  0.257 0.340
95.000  0.233 0.351 0.218  0.228  0.507 0.252 0.320 0.102  0.257 0.343
96.000  0.233 0.351 0.219  0.229  0.509 0.253 0.320 0.101  0.257 0.342
97.000  0.232 0.352 0.219  0.231  0.511 0.254 0.321 0.099  0.256 0.342

It must be emphasized that, precisely because it can read in free format, the vmatdat command cannot interpret blanks as zero entries. There must be a numerical value for all cells in the tables, including the 0’s.

The flexibility of vmatdat often makes it possible to read final demand columns or primary inputs as they appear in printed tables or on the disks provided by statistical offices.

For large models, it is convenient to be able to read “folded” vectors and store them in the default Vam file. This is the function of the fvread command. The usage is:

fvread <vector_name> <year> <skip>

<skip> is the number of columns to skip at the beginning of each line. There must be present as many elements as are in the vector, and they must be in order.

Example:

fvread fd 1997 10
finaldem 1   23 36 83 92 32
finaldem 6    8 23 73 80 75

This example will put the vector data (23, 36, 83, 92, 32, 8, 23, 73, 80, 75) into the fd vector of the default Vam file for the year 1997.