G7 Commands: V¶
vamcreate vam.cfg hist
At this point, the newly created Vam file has zeroes for all of its data.
Related Topics: dvam
Example: If am and cm are matrices and out, pdm, qcu, and cprices are vectors, we could write
vc out = am*out + out # Matrix multiplication, vector addition vc qcu = out*pdm # Element by element vector multiplication vc out = qcu/pdm # Element by element vector division vc cprices = pdm/cm # This is actually pdm' * cm. vc out{2017-2020} = qcu/pdm # Perform calculation over years 2017-2020. vc const = out{2017} # Set LHS series to a single year of the RHS.The <vector_name> must be a valid vector name in the Vam file, as must be all names in the expression.
Example:
ba outemp a vam hist b dvam b vf out1 = out1This seemingly tautological example actually does something useful. It will look first in the workspace bank for a series named out1, and if it fails to find it, will look in the bank assigned in position ‘a’, which is OUTEMP.BNK. Let’s say it finds the series there. It will then copy this series over to the default Vam file, which is HIST.VAM. The right hand side <expression> is any valid G7 expression, and the operation is effective over the current fdates.
In addition to the assignment operator (i.e. “=”), the vf command can add <expression> to the left-hand series using the “+=” operator, or it can subtract <expression> from the left-hand series with the “-=” operator, or multiply with “*=” or divide with “/=”. These operators follow the syntax for the C++ programming language, though here they operate over a range of values.
MatrixName( r|c <lines> )
where ‘r’ or ‘c’ indicate row or column and <lines> are the selected rows or columns. If the <lines> specification is omitted, then the default is all rows or columns. Each vector in the list is represented simply by its name. If the total number of lines in the sources is different from that of the target, then vmake uses the smaller number. The target may be a packed matrix, in which case the packed matrix file must have already been created, and the positions of the non-zero elements already determined. In this case, vmake will only store elements in the non-zero positions.
Each vector, whether it is a target or a source, is represented by:
VectorName( v <lines> )
where ‘v’ indicate that a vector is specified and <lines> are the selected elements. If the <lines> specification is omitted, then the default is all elements. Each vector in the list is represented simply by its name. If the total number of lines in the sources is different from that of the target, then vmake uses the smaller number. The target may be a packed matrix, in which case the packed matrix file must have already been created, and the positions of the non-zero elements already determined. In this case, vmake will only store elements in the non-zero positions.
The first example puts the vectors a, b and c in rows 1, 2 and 3 of matrix A.
vmake A(r 1-5) a b cThe next example puts column 3 of A into the vector c.
vmake c A(c 3)The final example puts fows of B starting from row 1 followed by the vector c into rows 2 to 100 of the matrix A.
vmake A(r 2-100) B(r) cRelated Topics: vmake
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.
In the above syntax, the arguments have the following meaning:
- <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 spaces on each line which 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 spaces 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 which 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 which have subtotals which 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 |**| 1598Columns which do not have an r are simply totally ignored. Consequently, they cannot be used to separate data fields. Thus, reading the following
rrrrrrrr rrrr 851 2971would 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 15would 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 which reads the vectors as rows, as may often 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 29Note 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, which 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.2Finally, here is an example which 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.346It 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, especially the 0’s.
The flexibility of vmatdat often makes it possible to read in final demand columns or primary inputs as they appear in printed tables provided by statistical offices.
Related Topics: matin
If one or more of the optional [line] entries are present, horizontal lines will be marked at those levels. The lighted pixels which mark these lines are located above the long marks on the horizontal axis, so they also serve as meaningful vertical lines.
Related Topics: vdata