<< Click to Display Table of Contents >> PRT |
![]() ![]() ![]() |
The PRT statement prints variables or expressions (you may use P, PRI or PRINT as synonyms for PRT). Note that printing mixed frequency timeseries is supported.
Guide: printing For an easier introductory guide on Gekko printing, see this page. |
Regarding series printing, the output can be transformed and formatted in different ways: transformations are done with so-called operators (for instance p or pch for percent change). Formatting includes transposing the result ('rows' option), setting width, decimals etc. The MULPRT statement is very similar to PRT, but compares data in the first-position and reference databanks. You may use the more detailed DISP statement, if you need more specific information regarding a series (data period, label, etc.: DISP also allows for equation browsing, if a model is loaded).
For variables taken from other banks than the first-position databank, you may use colon (':') to indicate the bankname, and for series you may use '!' to indicate a frequency different from the current frequency (for instance b2:x!q will print the quarterly series x!q, taken from the bank b2). You may use @x to indicate variables taken from the Ref (reference) databank (alternatively, you can use ref:x), and you may use <bank=... ref=...> to locally change the databanks used, instead of first using OPEN and then CLOSE. An array-series y can be printed with prt y;, where Gekko will print out all the elements in all dimensions. Otherwise prt y[#i]; may be used to print all #i (a list of strings) elements in a dimension, or y['a'] or the shorter y[a] can be used to print single elements.
PRT can also print out other variable types than series, for instance prt b2:#m; will print out #m, where #m could for instance be a list) from bank b2. Scalars can be printed with for instance prt %v;, where %v could for instance be a value. To show/count the number of variables of a particular type, you may use val ?, date ?, string ?, series ?, list ?, map ?, matrix ?, or MEM (for scalars).
Please note that after any PRT, you may click the Copy-button in the main window to copy-paste the print to Excel or other spreadsheets (CLIP will do the same thing, else see SHEET). Note that Gekko 3.0 supports printing (and plotting) series with mixed frequencies.
prt < period operators decimals width ROWS FILTER=... TITLE=... COLLAPSE=... NOMAX BANK=... REF=... SPLIT MISSING=... VIEW > elements FILE=filename;
•If no period is given inside the <...> angle brackets, the global period is used (cf. TIME).
•If a variable without databank indication is not found in the first-position databank, Gekko will look for it in other open databanks if databank search is active (cf. MODE).
where: |
|
period |
(Optional). Local period, for instance 2010 2020, 2010q1 2020q4 or %per1 %per2+1. |
operators |
operator operator ... |
operator |
'Long': abs, dif, pch, gdif, or 'short': n, d, p, dp, m, q, mp, l, dl, r, rd, rp, rdp, rl, rdl |
decimals |
DEC=number | NDEC=number | PDEC=number |
width |
WIDTH=number | NWIDTH=number | PWIDTH=number |
elements |
element element ... |
element |
variable label < operators decimals width > |
details: |
|
operators |
(See tables in examples section). Long operators: abs, dif, pch or gdif. These can be switched off by means of prefix no (for instance nopch), or added to existing default operators by means of underscore (for instance _dif). Default operators are abs and pch (absolute level and percentage growth is printed). Short operators: d, p and dp for time-transformations, and m, q and mp for multiplier-transformations. Prefix the time-transformations with r for reference values. See option print prt .... |
element |
The variable can be a variable name, a list (for instance {#m}), or an expression. A label can be provided after the variable (must be a string, and will be ignored for lists). Operators here will override other operators (globals ones, or those set on the PRT statement), so element-operators are local to the particular element. You may use for instance prt x x.fromseries('label'); to use label metadata. |
DEC |
Sets number of decimals, will apply to all kinds of numbers. |
NDEC |
Sets number of decimals for non-percentage numbers. See also option print fields ndec.... |
PDEC |
Sets number of decimals for percentage numbers. See also "option print fields pdec... |
WIDTH |
Sets width, will apply to all kinds of numbers. |
NWIDTH |
Sets width for non-percentage numbers. See also option print fields nwidth.... |
PWIDTH |
Sets width for percentage numbers. See also option print fields pwidth.... |
ROWS |
If set, the result will be transposed, i.e., with variables running downwards. Corresponds to TRANSPOSE=yes for SHEET and CLIP. |
FILTER |
A timefilter can be activated or deactivated (see TIMEFILTER statement). With <FILTER> or <FILTER=yes>, the current timefilter is used. With <NOFILTER> or <FILTER=no>, any filtering is deactivated. The filter type can also be changed locally, for instance <FILTER=hide> hides the out-filtered periods, whereas <FILTER=avg> averages the out-filtered periods. See option timefilter.... |
TITLE |
A title in quotes. You can use HEADING as alias. |
COLLAPSE |
(Optional). This option will collapse quarterly or monthly data into annual averages or totals. Use prt<collapse>, prt<collapse=avg> or prt<collapse=total>. You may set the collapse globally, cf. option print collapse = [avg|total|none];. Only applies for option print freq = pretty; (which is default). |
NOMAX |
(Optional). Do not restrict the number of variables, cf. option print elements max. |
BANK |
(Optional). A bankname where variables are looked up. For instance prt <bank = b1> x; is equivalent to prt b1:x;. See also <REF = ...>. These options can be convenient instead of opening and closing banks. |
REF |
(Optional). A bankname where reference variables are looked up. For instance prt <bank = b1 ref = b2 m> x; uses banks b1 and b2 for the multiplier. See also <BANK = ...>. These options can be convenient instead of opening and closing banks. |
SPLIT |
(Optional). If set, the variables or expressions delimited by comma are shown separately. In this way, prt x, y; is shown as if it had been prt x; prt y;. This may be practical for comparisons of data with similar columns, for instance prt <split> x[#i], @x[#i];. In that case, you may prefer to use for instance the <missing = m> option, so that all columns (#i) are shown (and are hence aligned), regardless of whether the sub-series exist or not. |
MISSING= |
(Optional). With <missing = ignore>, PRT will deal with missing array sub-series and missing data values like GAMS, treating them as zero for sums and mathematical expressions, or skipping the printing of a sub-series if it does not exist. The following options are set locally and reverted afterwards: option series array print missing = skip; option series array calc missing = zero; option series data missing = zero. See also the appendix page on missings. |
VIEW |
(Optional). Used for nested lists. With this option, Gekko starts up a graphical viewer, which is primarily (at the moment) intended for viewing nested lists. For instance, a list like #m = (('a', 'b'), ('c', 'd')); would look like the following with prt <view> #m;: In the longer run, views of series/array-series etc. may be implemented, too. The viewer handles convenient scrolling of large lists, and supports sorting etc. |
FILE |
(Optional). A filename that the print is put into. 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. |
There are two kinds of operators available. The easiest to remember are the 'long' ones: namely abs, dif, pch and gdif:
'Long' operators for PRT
abs |
Absolute level: x |
dif |
Absolute time change: x-x[-1] |
pch |
Growth rate: (x/x[-1] -1)*100 |
gdif |
Change in growth rate: (x/x[-1] -1)*100 - (x[-1]/x[-2] -1)*100 |
As default, PRT always prints out corresponding to prt<abs pch>, i.e., printing out the absolute level and the growth rate. These default options can be altered in option print prt ... (see 'Related options' below). For instance, to only print the level of a variable, use prt<abs>, to only print the growth rate, use prt<pch>, and to print absolute time change, use prt<dif>. You can alternatively switch off options with prefix no, for instance prt<nopch> (same as prt<abs>) etc. In addition, you can use the 'glue' prefix '_' to add options to existing options. For instance, prt<_dif> corresponds to prt<abs dif pch>, because dif is added to the default operators (abs and pch). You may put the codes after individual elements, for instance prt var1<pch> var2<dif>, to have var1 displayed as pch and var2 displayed as dif. Codes put on an element override more general codes put directly after PRT, so prt<pch> var1 var2<dif> yields the same result.
As a supplement to these 'long' operators, there are some more advanced (and shorter) operators of type d, p, m, q etc. These are perhaps less mnemotechnic, but more concise (the @ below indicates values taken from the reference databank):
'Short' operators for PRT
n |
Absolute level: x. Equivalent to no use of operators. |
d |
Absolute time change: x-x[-1] |
p |
Growth rate: (x/x[-1] -1)*100 |
dp |
Change in growth rate: (x/x[-1] -1)*100 - (x[-1]/x[-2] -1)*100 |
m |
Absolute multiplier: x-@x |
q |
Relative multiplier: (x/@x-1)*100 |
mp |
Multiplier in growth rate: (x/x[-1] -1)*100 - (@x/@x[-1] -1)*100 |
l |
Log: log(x). [New in 3.0.3]. |
dl |
Log-difference: log(x)-log(x[-1]). [New in 3.0.3]. |
r |
Absolute level in reference databank: @x. Code 'rn' is equivalent. |
rd |
Absolute time change in the reference databank: x-x[-1] |
rp |
Growth rate in reference databank: (@x/@x[-1] -1)*100 |
rdp |
Change in growth rate in reference databank: (@x/@x[-1] -1)*100 - (@x[-1]/@x[-2] -1)*100 |
rl |
Log: log(@x) |
rdl |
Log-difference: log(@x)-log(@x[-1]) |
There is the following logic to the above codes. The important codes to remember are d for absolute time change, p for percent time change, m for absolute multiplier, and q for relative multiplier. Then the combination dp is easily read as time change in growth rate, and mp as multiplier difference in growth rate. Log-transformations are done with l or dl operators. This covers the first and second sections of the above table. The third section is just the first section with prefix r (for reference databank), and shows that same transformations as in the first section, just for the reference databank values instead of the first-position databank values. Of course, you can always write prt <p> @gdp; instead of prt <rp> gdp;, but for longer expressions and lists, the prefix r comes in handy.
In addition to the above transformations, the print can be formatted regarding the width of each data column, and the number of decimals. Width and decimals can be set in the PRT option field, or in element option fields. In the PRT option field, you may indicate the width and number of decimals like this: prt<width=10 dec=3>, or you may set absolute and percentage fields individually: prt<nwidth=10 ndec=0 pwidth=6 pdec=1>. This will yield absolute fields 10 characters wide with no decimals, and percentage fields 6 characters wide with 1 decimal. The width and decimals formatting can also be applied individually on each element, for instance prt gdp<n dec=0> pgdp<p dec=1>, printing gdp in levels with no decimals, and pgdp as growth rate with 1 decimal.
The output can be transposed by means of the rows keyword, for instance prt<rows>gdp pgdp;. This is handy for printing a long list of timeseries, or for copy-pasting the cells to a spreadsheet by means of the copy-button in the Gekko interface.
Finally, you can use a timefilter (see TIMEFILTER) in the PRT option field. This is convenient for suppressing individual observations when printing long time periods. First, you need to select the filtered periods, and then you can use for instanceprt <filter> or prt<nofilter>. More advanced use is prt<filter=avg> in which case the out-filtered periods are aggregated into the shown periods (rather than simply skipped). See examples below.
Mixed frequencies
PRT can print out series of mixed frequencies in the same 'table' (frequencies a, q, m mixed, or frequencies m, d mixed), for example:
time 2001 2002; |
The following is printed:
xx1 % xx2!q % |
You may mix frequencies !a, !q and !m or !m and !d as you like, and mixed frequencies work for PLOT, too. Note that Gekko supports auto-collapse when printing, for instance prt <collapse=total> xx2!q; (this will print yearly totals).
A simple example:
time 2009 2012; |
This gives the following result, with both absolute levels and percentage growth:
x % real % |
The label for x/p is given as a string after the expression. Please use a space to delimit variable and label. If a model is loaded, and x is a model variable, the first '%' would become '(E)%', because (E) or (X) are used to indicate endogenous or exogenous variables. Using operator p inside the option brackets would provide you with the growth rates alone (the long operator pch has the same effect):
prt <p> x, x/p; |
The print can alternatively be transposed with the <rows> option like this:
prt <2010 2012 p rows> x, x/p; |
gives:
2010 2011 2012 |
You may mix variables, lists, expressions and operators as you wish (just separate the elements with commas):
time 2009 2012; |
Please note that the list #m is inside {}-curlies, because we are referring to the variables corresponding to the strings in the list. This prints out absolute time-differences in these variables/lists/expressions:
xa[ |
If xa and xb are understood as, for instance, sectors a and b, you may instead use a list of these sector names, and then use x{#m} to auto-unfold into the variable names xa and xb.
time 2009 2012; xa = (10, 12, 11, 14); xb = (6, 5, 7, 6); time 2010 2012; |
Multiple operators can be used in one option field, as this example shows:
prt <n p r rp m q> fy; |
This corresponds to a hand-made version of the MULPRT<v> statement, printing levels/growth in the first-position and reference databanks in addition to the multiplier differences (absolute and relative). As you see, this PRT statement contains multiplier differences (codes m and q), so by means of using short operators you are free to mix multiplier values into the print.
Formatting can be applied in the following way:
prt <nwidth=10 ndec=0 pwidth=6 pdec=1> fy; |
This prints out the absolute levels and percentage growth rates (this way of printing is default, see option print prt...), with width 10 and no decimals for the levels, and width 6 and 1 decimal for the growth rates. You may use formatting on each element, for instance:
prt fy, fx, fm<ndec=0 pdec=1>; |
In that case, only the last variable (fm) has a different number of decimals. Fixed periods can be indicated in brackets (for instance [2005] means that 2005-values are taken). Different databanks may be indicated:
prt fy, @fy, old:fy, old:{#m}; |
This prints out the variable fy from the first-position databank, fy from the Ref (reference) databank (@-indicator), fy from a databank with the name old, and variables corresponding to the list of strings #m, all taken from the old databank. The latter is opened by means of the OPEN statement (note that you can use F2 to see the list of open databanks).
Wild-card lists (inside braces {...}) may be used instead of regular lists:
prt {'fx*2'}; |
This will print out all variables starting with fX and ending with 2 in the first-position databank (use '?' as a single-character wild-card). In come statements, you may use for instance fx*2 directly instead of {'fx*2'}, but in PRT this would be ambiguous (is fx*2 a wildcard, or is it fx multiplied by 2?).
You may insert labels or a heading into the PRT statement, the former only for non-list items.
prt fy 'GDP', ul 'Unemployment' heading = 'Scenario A'; |
To filter out periods, first define a TIMEFILTER. For instance:
timefilter 2003, 2005..2008, 2010..2015 by 2; |
This way, the periods 2004, 2009, 2011 and 2013 will be hidden, whereas all other periods are shown. Note that TIMEFILTER defines the periods positively, i.e. the periods that are to be included when printing. If you print now, these four periods will just be skipped. To temporarily disable the filter in the print, use prt<nofilter>. To have the skipped periods aggregated into the shown periods, use prt<filter=avg>. For instance:
prt<2003 2015 filter=avg>fY; |
gives the following:
fY [%] |
For e.g. 2004-2005, the average for these two periods is shown. For the absolute level (the 'fY' column), a simple average is used, whereas for the percentage column ('[%]'), a more complicated averaging of growth rates is performed, in order to yield a consistent average growth rate for these two periods.
Looping over lists in combination with PRT is pretty straightforward. You may write:
for string %i = yf, x; |
This will print the series fyfnf, fyfnz, fxnf, fxnz. If you are using Gekko interactively, you can obtain non-executing linebreaks by means of Ctrl+Enter, and you execute the block of statements by means of marking the block before pressing [Enter]. Alternatively, and better, RUN the statements from a program file.
The example above can be done more easily (and will print them in one print):
#i = yf, x; |
Note
If a model is loaded (see MODEL), the PRT statement indicates '(E)' for endogenous, and '(X)' for exogenous variables. Missing values are shown with a 'M' instead of numbers. If some variable is missing in the databank (or the databank does not exist), an error message will be issued.
Note that prt <m> mybank:x; prints out the difference mybank:x - @x (and prt <r> mybank:x; prints out @x), where @x is x in the Ref (reference) databank. So when printing a multiplier involving a named (OPEN) databank, Gekko will look for the same variable in the reference databank, in order to compute the multiplier.
You may change what is printed as default via the option print prt ... options (see 'Related options' below). For instance you may want to switch off printing of percentage growth permanently: option print prt pch = no.
You may use P, PRI or PRINT instead of PRT. You may use diff instead of the dif operator.
Related options
Relevant options regarding the PRT statement:
OPTION freq a; [a|q|m|d|u]
OPTION print collapse = none; [avg|total|none]; //show aggregates for quarters and months
OPTION print freq = pretty; [pretty|simple]; //for quarters and months
OPTION print width = 100;
OPTION print fields ndec = 4;
OPTION print fields nwidth = 13;
OPTION print fields pdec = 2;
OPTION print fields pwidth = 8;
OPTION print prt abs = yes;
OPTION print prt dif = no;
OPTION print prt pch = yes;
OPTION print prt gdif = no;
OPTION series array print missing = error; [error|m|zero|skip]
OPTION series data print missing = error; [error|m|zero|skip]
OPTION series normal print missing = error; [error|m|zero|skip]
OPTION timefilter type = hide;
OPTION timefilter = no;
Related statements
MULPRT, PLOT, SHEET, CLIP, DISP, DECOMP