Preprogrammed table making utility: Gams2tbl

Top  Previous  Next

Rutherford has developed a preprogrammed table making utility using put commands called Gams2tbl.gms that he documents and distributes through http://www.mpsge.org/inclib/gams2tbl.htm Gams2tbl is a gms file that users can include in their program through a Libinclude or Batinclude that contains numerous formatting options.  Gams2tbl and some of its formatting capabilities are illustrated in the following example (canput.gms)

 

set columns / a Horses,b Cows,c Chickens/

set rows /r1 Housing,r2 Land,r3 Feed/

table data (rows,columns) Table with default formatting

              a            b              c

r1            1          14.8233        12.99

r2            2           12              2.2

r3            3           11              3.2;

file ruthput ; put ruthput ;

$libinclude GAMS2tbl

$libinclude GAMS2tbl data

parameter roworder(rows) /r1 3,r2 1,r3 2/;

parameter colorder(columns) /a 2,b 3, c 1/  ;

$setglobal row_order roworder

$setglobal col_order colorder

$setglobal title "Table 2 where item ordering is controlled"

$libinclude GAMS2tbl data

$setglobal row_label rows

$setglobal col_label columns

$setglobal title "Table 3 where labels for sets are used"

$libinclude GAMS2tbl data

parameter decimals(columns) /a 0,b 4 ,c 1/  ;

$setglobal c_decimals decimals

$setglobal title "Table 4 where decimals are controlled"

$libinclude GAMS2tbl data

 

Yields the resultant output

 

Table 1 with default formatting

 

           a           b           c

 

r1      1.00       14.82       12.99

r2      2.00       12.00        2.20

r3      3.00       11.00        3.20

 

 

Table 2 where item ordering controlled

 

           c           a           b 

r2      2.20        2.00       12.00

r3      3.20        3.00       11.00

r1     12.99        1.00       14.82

Table 3 where labels for set items used

 

       Chickens     Horses       Cows

 

Land       2.20       2.00      12.00

Feed       3.20       3.00      11.00

Housing   12.99       1.00      14.82

 

 

Table 4 where decimals are controlled

                 

       Chickens     Horses       Cows

 

Land        2.2          2    12.0000

Feed        3.2          3    11.0000

Housing    13.0          1    14.8233

 

Tables can be made in regular text, HTML or Latex formats.