WRITE

<< Click to Display Table of Contents >>

Navigation:  Gekko User Manual > Gekko statements >

WRITE

Previous pageReturn to chapter overviewNext page

The statement writes variables to a Gekko databank file (.gbk). A .gbk file is a Gekko-specific binary databank format that stores series, values, dates, strings, lists, maps, and matrices.

 


 

Syntax

 

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.

 

There is the following equivalence between 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.

 

 


 

Examples

 

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> fy, fe, fm FILE=sim4050;

 

This produces the file sim4050.gbk, containing the three variables fy, fe, fm 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:

 

#= fy, fe, fm;    //or: #m = ('fy', 'fe', 'fm);
write <2040 2050> {#m} FILE=sim4050;

 

Without the braces, the list #m itself would have been written, not the three series.

 


 

Note

 

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.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.

 


 

Related options

 

OPTION folder bank = [empty];

 

 


 

Related statements

 

READ, IMPORT, EXPORT, SHEET, MODEL, HDG