|
<< Click to Display Table of Contents >> WRITE |
![]() ![]()
|
The statement writes variables to a Gekko databank file (.gbk). A .gbk file is a Gekko-specific binary databank format that stores all Gekko variables: series, values, dates, strings, lists, maps, and matrices. You can also use for instance write<xlsx> to write data in other formats than .gbk, but beware that there are differences between WRITE and EXPORT regarding time periods used. See the EXPORT help page for other data formats than .gbk.
There is the following equivalence between the close cousins WRITE and EXPORT: write = export<all>, and the inverse: export = write<respect>. If a local <> period is set, WRITE and EXPORT behave in the same way.
A user-defined heading can be added to a .gbk file with the HDG statement.
write < period RESPECT TRACE=... > filename ;
write < period RESPECT TRACE=... > variables FILE=filename ;
period |
(Optional). Without a time period indicated, Gekko will write all the data for all observations. When a period is indicated, the written data(bank) is truncated. |
RESPECT |
(Optional). With this option, if no period is given, the global period is used. |
TRACE= |
(Optional). Use yes or no, yes is default. With trace=no, no data-traces are written. |
variables |
Variables or lists (wildcards and bank indicators may be used), and items may be separated by commas. If no variables are given, the full first-position databank is written. |
filename |
Filenames may contain an absolute path like c:\projects\gekko\bank.gbk, or a relative path \gekko\bank.gbk. Filenames containing blanks and special characters should be put inside quotes. Regarding reading of files, files in libraries can be referred to with colon (for instance lib1:bank.gbk), and "zip paths" are allowed too (for instance c:\projects\data.zip\bank.gbk). See more on filenames here. |
•If no period is given inside the <...> angle brackets, no time period is used.
•If a variable is stated without databank, the databank is assumed to be the first-position databank.
You may write the contents of the first-position databank like this:
write data; |
This will produce the file data.gbk, containing the first-position databank. If you only want subset of the variables (or a subset of the time period), you may write for instance:
write<2040 2050> x1, x2, x3 file=sim4050; |
This produces the file sim4050.gbk, containing the three variables x1, x2, x3 over the period 2040-50. If practical, you may also use wild-card lists:
write fx* file=fxfile; |
This writes all variables starting with fX to the file fxfile.gbk. Actually write ** file=databank; is equivalent to write databank;, cf. the wildcards page regarding the double star ** notation. To write a list of strings containing variable names, use {}-curlies:
#m = x1, x2, x3; //or: #m = ('x1', 'x2', 'x3'); |
Without the braces, the list #m itself would have been written, not the three series.
If option folder = yes, and option folder bank is set, the WRITE statement tries to write to that particular folder instead of the working folder.
If a model has been loaded, and all the endogenous variables of the model exist in the first-position databank, the WRITE statement will store info regarding the model, last simulation period etc. inside the .gbk file. After this, when reading the databank again, a link to this model info is provided. This can be practical when in doubt about when the variables in a given databank were simulated, the simulation period, the model name and signature, etc.
Gekko 3.x always writes a gbk databank in the 1.2 format version. See more about .gbk formats under the READ statement, including how to exchange data between newer and older Gekko versions.
See the Gekko menu 'Options' --> 'Program dependency tracking' or use option global dependency tracking = ...; to activate dependency tracking, so that the use of external files (for instance program files, read/written databanks etc.) are shown as a list at the end of a Gekko session.
option databank file gbk compress = yes;
option databank file gbk internal = databank.data;
option folder bank = '';
option folder bank1 = '';
option folder bank2 = '';
option interface csv decimalseparator = period;
option interface csv delimiter = semicolon;
option interface csv ignoremissing = no;
option interface csv ndec = 100;
option interface excel ignoremissing = no;
option interface excel language = danish;
option interface excel modernlook = yes;
option interface prn decimalseparator = period;
option interface prn delimiter = blank;
option interface prn ndec = 100;
HDG, IMPORT, READ, SHEET, WRITE