Writing Vam File Data to ASCII FilesΒΆ

It sometimes is necessary to take data from a Vam file and print it to an ASCII file. For example, we may have used the Windows cut and paste commands to move data from a spreadsheet into the window of the show command, but we want an ASCII version of the file so that we will not need to repeat this manual procedure if we rebuild the Vam file from scratch. The following commands provide several ways to print matrix and vector data to files that easily can be read back by G7 or, in some cases, by other programs.

pmpunch <filename> <matname> [precision]
The non-zero elements of the matrix <matname> are written into the named file <filename> as input for the pmatin command. The <precision> argument gives the number of decimal places. The years to be written are determined by the current values of fdates. This command especially is useful for converting a rectangular matrix in a Vam file into a packed matrix. One writes it out as an ASCII file with this command and then reads it in with the pmatin command.
punchvec <filename> <vecname> <startyear> <endyear> [<width> <precision>]
Print a vector to a file for all sectors, for the years specified. The optional <width> and <precision> arguments again specify the field width and number of decimal places. The output file starts with a number of comment lines, telling the name of the vector, starting and ending years, and format information. Then one comment line gives the years as column headings. Each following line of the file contains the time series for one sector, with the name of the series followed by the time series of data.
punch5 <filename> <vecname> [<width> <precision> <IndexWidth>]
Print a matrix or packed matrix to a file in punch5 format. The years written are determined by the current value of fdates. Each year is written with a header that is a matin5 command, which tells matin5 also what field width, precision, and index width to use. (The <IndexWidth> parameter is the width of the row and column numbers in the file.) Thus, a file created with punch5 can be read back into G7 using the matin5 command. This provides a convenient way to convert packed matrices into normal matrices. The punch5 format prints 5 non-zero matrix cells to a line, with row number, column number, and cell value for each cell.
vp <vector_name> [r|c] [field_width] [decimal_points]
vp <matrix_name> <view><line> [field_width] [decimal_points]
Write the named matrix to the currently open “save” file. As you can see, this command has a format and options like those of the show command.

For example:

save am.dat
vp am y 2000  9  6
save off

Note that the use of save files in conjunction with the matty or type commands also are useful ways to capture Vam data in ASCII form file. Furthermore, since the Compare program can work with Vam files, you can use the \gdata command in that program to make neat ASCII file printouts of vector or matrix time series from a Vam file.

Previous topic

The Coef, Flow, Getsum, Load, and Store Commands

Next topic

Titles for Vam Files

This Page