A GAMS Program which Maps
Social Accounting Data into Labelled Submatrices

Thomas F. Rutherford

Department of Economics
University of Colorado

rutherford@colorado.edu

2003


A common data manipulation exercise for GAMS programmers building CGE models involves moving numbers from a square social accounting matrix with numeric indices to model-relevant subtraces with meaninful text labels. It would, of course, be possible to construct the CGE model without relabelling the data, but this would require that the economist juggle lots of random bits of data in his head ("Let's see, row 116 references the government, and row 118 references import tariffs..."). A very important advantage conferred by GAMS is the use of text labels which permit ready interpretation of model output with reference to a index.

The easiest way to move data from a SAM into submatrices is to rely on "tuples". These are multidimensional sets which can associated a numeric index with a text index. In this example, the SAM has 124 rows and columns, and this list is partitioned into 10 logical subsets:


	Production activities	A (43)
	Commodities		C (43)
	Trade Margins		M (3)
	Primary Factors		F (13)
	Enterprises		E (1)
	Private households	H (12)
	Government		G (1)
	Types of taxes		T (6)
	Rest of world		X (1)
	Investment-savings	I (1)

Here is a "MAP" of the SAM with the names of the submatrices which contain data. All cells with no labels are empty:

	   A	   C	   M	   F	   E	   H	   G	   T	   X	   I
	--------------------------------------------------------------------------------
A	|	|   ac	|	|	|	|   ha	|	|	|	|
	--------------------------------------------------------------------------------
C	|   ca	|	|   cm	|	|	|   ch	|   gd	|   	|   er	|   cs
	--------------------------------------------------------------------------------
M	|	|   mc	|	|	|	|	|	|	|	|	
	--------------------------------------------------------------------------------
F	|   fa	|	|	|	|	|	|	|	|	|	
	--------------------------------------------------------------------------------
E	|	|	|	|   ef	|	|	|	|	|	|	
	--------------------------------------------------------------------------------
H	|	|	|	|   hf	|   he	|	|   hg	|	|   hr	|		
	--------------------------------------------------------------------------------
G	|	|	|	|   gf	|   ge	|	|	|   tr	|	|	
	--------------------------------------------------------------------------------
T	|   ta	|   tc	|	|   tf	|   te	|   tp	|	|	|	|	
	--------------------------------------------------------------------------------
X	|	|   rc	|	|   rf	|	|	|	|	|	|	
	--------------------------------------------------------------------------------
I	|	|	|	|   dp	|	|  psv	|   gsv	|	|   fsv	|	
	--------------------------------------------------------------------------------

A square SAM is balanced when the rows sums equal the column sums, roughly corresponding to the conventional notion of double-entry book-keeping. This implies the following identies:


(A)	ca + fa + ta = ac + ha
(C)	ac + mc + tc + tc = ca + cm + ch + gd + er + cs
(M)	cm = mc
(F)	ef + hf + gf + tf + rf + dp = fa
(E)	he + ge + te = ef
(H)	ha + ch + tp + psv = hf + he + hg + hr
(G)	gd + hg + gsv = gf + ge + tr
(T)	tr = ta  tc + tf + te + tp
(X)	er + hr + fsv = rc + rf
(I)	cs = dp + psv + gsv + fsv  

The program verifies these consistency checks by compute the following totals matrix:

----   1962 PARAMETER totals  SAM totals

             A        C        M        F        E        H        G        T        X        I     total
A               12098.0                              1949.5                                       14047.4
C       6449.8             355.7                     4953.7    513.9            1305.7   1318.7   14897.5	 
M                 355.7	     	     	     	     	             	    	 	   	    355.7	 
F       7576.3	     	     	     	     	     	                         	 	   7576.3	 
E                                  2268.5    	     	             	     	   	           2268.5	 
H                                  5264.8   2171.5              61.4             402.6	  	   7900.3	 
G                                              1.0                      665.6	     	  	    666.6	 
T         21.3    436.3              18.1     96.0     93.9          	     	                    665.6	 
X                2007.5              25.0    	     	             	     	   	           2032.5	 
I                                                     903.2     91.3             324.3	  	   1318.7	 
total  14047.4  14897.5    355.7   7576.3   2268.5   7900.3    666.6    665.6   2032.5   1318.7   	 
The previous program which must be previously processed is tzabal. The next program is tzamdl in which the submatrices produced by this program are used in an GAMS/MPSGE model. Invocation of this program from the command line is:

gams tzamap gdx=tzamap


$title	Map the TZA data from the square social accounting matrix into relabelled submatrices

*	Declare "chk" so that check sums are displayed in the first column of output:

set colorder /chk/;

*	Read the balanced SAM data:

set     i   SAM rows and column indices   /1*124/; alias  (i,j);
parameter sam(i,j)  Base year social accounts;

$gdxin 'tzabal.gdx'
$load sam


set	negval(i,j)	Flag for negative elements;
negval(i,j) = yes$(sam(i,j) < 0);
display negval;

set	empty(i,*)	Flag for empty rows and columns;
empty(i,"row") = 1$(sum(j, sam(i,j)) = 0);
empty(j,"col") = 1$(sum(i, sam(i,j)) = 0);
display empty;


*	Declare sets with which the SAM data should be relabelled:

SET
        s   List of activities and commodities/
                MAIZE  Growing of maize,
                PADDY  Growing of paddy,
                SORGH  Growing of sorghum and millet,
                WHEAT  Growing of wheat,
                BEANS  Growing of beans,
                CASSA  Growing of cassave,
                CEREA  Growing of other cereals,
                OILSE  Growing of oil seeds,
                ROOTS  Growing of other roots and tubers,
                COTTO  Growing of cotton,
                COFFE  Growing of coffee,
                TOBAC  Growing of Tobaco,
                TEAGR  Growing of tea,
                CASHE  Growing of cashew nuts,
                SISAL  Growing of sisal fiber,
                SUGAR  Growing of sugar cane ,
                OFRVE  Growing of fruits and vegetables,
                OCROP  Growing of other crops,
                LIVES  Operation of poultry and livestock,
                FISHI  Fishing and fish farms,
                HUFOR Hunting and forestry,
                MININ Mining and quarying,
                MEATD Processing of meat and dairy products,
                GRAIN Grain milling,
                PFOOD Processed food,
                BEVER Beverage and tobacco products,
                CLOTH Textile and leather products,
                WOODP Wood paper printing,
                CHEMI Manufacrure of basic and industrial chemicals,
                FERTI Manufacturer of fertilizer and pesticides,
                PETRO Petroleum refinaries,
                RUPLA Rubber plastic and other manufacturing,
                GLASS Glass and cement,
                METAL Iron steel and metal products,
                EQUIP Manufacture all equipment,
                UTILI Utilities,
                CONST Construction,
                TRADE Wholesale and retail trade'
                HOTEL Hotels and restaurant,
                TRANS Transport and communication,
                ESTAT Real estate,
                ADMIN Public administration health and education,
                PRIVS Business and other services /,

            M Margins /
                CTDTP-E Export transactions costs,
                CTDTP-D Domestic sales transactions costs,
                CTDTP-M Import transactions costs /,

          F Factors of production /
                FSUB    Subsistence factor,
                LCHILD  Child labor age 10 to 14,
                LNONF   Female laboe with no formal education,
                LNFPF   Female labor nonfinished primary school,
                LNFSF   Female labor nonfinished secondary school,
                LSECF   Female labor secondary or higher education,

                LNONM   Male labor with no formal education,
                LNFPM   Male labor nonfinished primary school,
                LNFSM   Male labor nonfinished secondary school,
                LSECM   Male labor secondary or higher education,

                CAPAG   Agricultural capital,
                CAPNAG  Non-agricultural capital,
                LAND    Agricultural land /,

        E Enterprise Account  / ENTR / ,

        H Household Groups /
                HRBFPL  Rural below food poverty line,
                HRFBPL  Rural between basic needs poverty line,
                HRNOED  Rural nonpoor head with non education,
                HRNFPS  Rural nonpoor head not finished primary school,
                HRNFSS  Rural nonpoor head not finished secondary school,
                HRSECP  Rural nonpoor head finished secondary school,
                HUBFPL  Urban below food poverty line,
                HUFBPL  Urban between basic needs poverty line,
                HUNOED  Urban nonpoor head with non education,
                HUNFPS  Urban nonpoor head not finished primary school,
                HUNFSS  Urban nonpoor head not finished secondary school,
                HUSECP  Urban nonpoor head finished secondary school/ ,

        T Taxes /
                DIRTAX  Direct taxes on domestic products,
                IMPTAX  Import tariff,
                EXPTAX  Export taxes,
                VATAX   Value added or activity taxes,
                INDTAX  Indirect or sales taxes,
                FACTAX  Factor taxes /

alias  (i,j), (s,g), (m,mm);

* Mapping the activities

       Set mapa(i,s) Mapping from SAM to activities less cotton and textile /
                 1.MAIZE,
                 2.PADDY,
                 3.SORGH,
                 4.WHEAT,
                 5.BEANS,
                 6.CASSA,
                 7.CEREA,
                 8.OILSE,
                 9.ROOTS,
                 10.COTTO,
                 11.COFFE,
                 12.TOBAC,
                 13.TEAGR,
                 14.CASHE,
                 15.SISAL,
                 16.SUGAR,
                 17.OFRVE,
                 18.OCROP,
                 19.LIVES,
                 20.FISHI,
                 21.HUFOR,
                 22.MININ,
                 23.MEATD,
                 24.GRAIN,
                 25.PFOOD,
                 26.BEVER,
                 27.CLOTH,
                 28.WOODP,
                 29.CHEMI,
                 30.FERTI,
                 31.PETRO,
                 32.RUPLA,
                 33.GLASS,
                 34.METAL,
                 35.EQUIP,
                 36.UTILI,
                 37.CONST,
                 38.TRADE,
                 39.HOTEL,
                 40.TRANS,
                 41.ESTAT,
                 42.ADMIN,
                 43.PRIVS /,

         mapc(i,g)  mapping from SAM to commodities  less cotton and textile/
                 44.MAIZE,
                 45.PADDY,
                 46.SORGH,
                 47.WHEAT,
                 48.BEANS,
                 49.CASSA,
                 50.CEREA,
                 51.OILSE,
                 52.ROOTS,
                 53.COTTO,
                 54.COFFE,
                 55.TOBAC,
                 56.TEAGR,
                 57.CASHE,
                 58.SISAL,
                 59.SUGAR,
                 60.OFRVE,
                 61.OCROP,
                 62.LIVES,
                 63.FISHI,
                 64.HUFOR,
                 65.MININ,
                 66.MEATD,
                 67.GRAIN,
                 68.PFOOD,
                 69.BEVER,
                 70.CLOTH,
                 71.WOODP,
                 72.CHEMI,
                 73.FERTI,
                 74.PETRO,
                 75.RUPLA,
                 76.GLASS,
                 77.METAL,
                 78.EQUIP,
                 79.UTILI,
                 80.CONST,
                 81.TRADE,
                 82.HOTEL,
                 83.TRANS,
                 84.ESTAT,
                 85.ADMIN,
                 86.PRIVS  /,

           mapm(i,m) mapping from SAM to marketing margins /
                 87.CTDTP-E,
                 88.CTDTP-D,
                 89.CTDTP-M /,

          mapf(i,f) mapping from SAM to factors of production /
                 90.FSUB,
                 91.LCHILD,
                 92.LNONF,
                 93.LNFPF,
                 94.LNFSF,
                 95.LSECF,
                 96.LNONM,
                 97.LNFPM,
                 98.LNFSM,
                 99.LSECM,
                 100.CAPAG,
                 101.CAPNAG,
                 102.LAND /,

           mape(i) mapping from SAM to enterprise account  /103 /,

           maph(i,h) mapping from SAM to household groups/
                 104.HRBFPL,
                 105.HRFBPL,
                 106.HRNOED,
                 107.HRNFPS,
                 108.HRNFSS,
                 109.HRSECP,
                 110.HUBFPL,
                 111.HUFBPL,
                 112.HUNOED,
                 113.HUNFPS,
                 114.HUNFSS,
                 115.HUSECP  /,

            mapg(i) identifying government row /116 /,

            mapt(i,t) mapping from SAM to source of taxes /
                 117.DIRTAX,
                 118.IMPTAX,
                 119.EXPTAX,
                 120.VATAX,
                 121.INDTAX,
                 122.FACTAX  /,

            mapx(i) identifing the rest of the world /123 /,

            mapi(i) identifying the investment and saving row/124/;


*	Generate a report of submatrix totals:

set	ss /A, C, M, F, E, H, G, T, X, I/

parameter	totals(*,*)	SAM totals for reporting;
totals("A","C") = sum((mapa(i,s),mapc(j,g)), sam(i,j));
totals("A","H") = sum((mapa(i,s),maph(j,h)), sam(i,j));
totals("C","A") = sum((mapc(i,g),mapa(j,s)), sam(i,j));
totals("C","M") = sum((mapc(i,g),mapm(j,m)), sam(i,j));
totals("C","H") = sum((mapc(i,g),maph(j,h)), sam(i,j));
totals("C","G") = sum((mapc(i,g),mapg(j)), sam(i,j));
totals("C","X") = sum((mapc(i,g),mapx(j)), sam(i,j));
totals("C","I") = sum((mapc(i,g),mapi(j)), sam(i,j));
totals("M","C") = sum((mapm(i,m),mapc(j,g)), sam(i,j));
totals("F","A") = sum((mapf(i,f),mapa(j,s)), sam(i,j));
totals("E","F") = sum((mape(i),mapf(j,f)), sam(i,j));
totals("H","F") = sum((maph(i,h),mapf(j,f)), sam(i,j));
totals("H","E") = sum((maph(i,h),mape(j)), sam(i,j));
totals("H","G") = sum((maph(i,h),mapg(j)), sam(i,j));
totals("H","X") = sum((maph(i,h),mapx(j)), sam(i,j));
totals("G","F") = sum((mapg(i),mapf(j,f)), sam(i,j));
totals("G","E") = sum((mapg(i),mape(j)), sam(i,j));
totals("G","T") = sum((mapg(i),mapt(j,t)), sam(i,j));
totals("T","A") = sum((mapt(i,t),mapa(j,s)), sam(i,j));
totals("T","C") = sum((mapt(i,t),mapc(j,g)), sam(i,j));
totals("T","F") = sum((mapt(i,t),mapf(j,f)), sam(i,j));
totals("T","E") = sum((mapt(i,t),mape(j)), sam(i,j));
totals("T","H") = sum((mapt(i,t),maph(j,h)), sam(i,j));
totals("X","C") = sum((mapx(i),mapc(j,g)), sam(i,j));
totals("X","F") = sum((mapx(i),mapf(j,f)), sam(i,j));
totals("I","F") = sum((mapi(i),mapf(j,f)), sam(i,j));
totals("I","H") = sum((mapi(i),maph(j,h)), sam(i,j));
totals("I","G") = sum((mapi(i),mapg(j)), sam(i,j));
totals("I","X") = sum((mapi(i),mapx(j)), sam(i,j));
alias (ss,sss);
totals(ss,"total") = sum(sss, totals(ss,sss));
totals("total",ss) = sum(sss, totals(sss,ss));
option totals:1;
display totals;

*	Extract submatrices from the SAM.  When a submatrix is extracted,
*	set the associated value to zero so that it is possible to verify 
*	at the end of the program that all the data has been extracted.

*	1) Domestic production is associated with an exhaustion of product
*	condition.  First extract all submatrices related to production.

parameter
	ca(g,s)        Intermediate inputs demand,
	fa(f,s)        Factor demand or value added,
	ta(t,s)        Tax collection,
	ha(s,h)        Household consumption of own production,
	ac(s,g)        Marketed output;

loop((mapc(i,g), mapa(j,s)),         ca(g,s) = sam(i,j); sam(i,j)=0; );
loop((mapf(i,f), mapa(j,s)),         fa(f,s) = sam(i,j); sam(i,j)=0; );
loop((mapt(i,t), mapa(j,s)),         ta(t,s) = sam(i,j); sam(i,j)=0; );
loop((mapa(i,s), maph(j,h)),         ha(s,h) = sam(i,j); sam(i,j)=0; );
loop((mapa(i,s), mapc(j,g)),         ac(s,g) = sam(i,j); sam(i,j)=0; );

*	Then check that the data balances.  This check provides a clean representation
*	of how the benchmark data is organized and how it balances:

parameter	profit(s,*)	Zero profit check for sectors;
profit(s,"ac") = sum(g, ac(s,g));
profit(s,"ha") = sum(h, ha(s,h));
profit(s,"ta") = sum(t, ta(t,s));
profit(s,"ca") = sum(g, ca(g,s));
profit(s,"fa") = sum(f, fa(f,s));
profit(s,"chk") = profit(s,"ac") + profit(s,"ha") - profit(s,"ta") - profit(s,"ca") - profit(s,"fa");
display profit, ta;

*	2) Goods markets are associated with a supply-demand balance
*	condition.  We extract the related submatrices and verify that
*	market clearance conditions are satisfied.

PARAMETER
	mc(m,g)        Marketing and transportation costs
	tc(t,g)        Indirect taxes
	rc(g)          Value of imports at (cif)

	cm(g,m)        Sales to wholesale and retail margins 
	gd(g)          Government Demand
	er(g)          Export (fob),
	cs(g)          Private investiment demand,
	ch(g,h)        Private consumption;

loop((mapm(i,m), mapc(j,g)),         mc(m,g) = sam(i,j); sam(i,j)=0; );
loop((mapt(i,t), mapc(j,g)),         tc(t,g) = sam(i,j); sam(i,j)=0; );
loop((mapx(i),   mapc(j,g)),         rc(g) = sam(i,j);	sam(i,j)=0; );

loop((mapc(i,g), mapm(j,m)),         cm(g,m) = sam(i,j); sam(i,j)=0; );
loop((mapc(i,g), mapg(j)),           gd(g) = sam(i,j);	sam(i,j)=0; );
loop((mapc(i,g), mapx(j)),           er(g)  = sam(i,j); sam(i,j)=0; );
loop((mapc(i,g), mapi(j)),           cs(g) = sam(i,j);	sam(i,j)=0; );
loop((mapc(i,g), maph(j,h)),         ch(g,h) = sam(i,j); sam(i,j)=0; );

parameter gmkt(g,*)	Goods market clearance;
gmkt(g,"ac") = sum(s, ac(s,g));
gmkt(g,"mc") = sum(m, mc(m,g));
gmkt(g,"tc") = sum(t, tc(t,g));
gmkt(g,"rc") = rc(g);
gmkt(g,"ca") = sum(s, ca(g,s));
gmkt(g,"cm") = sum(m, cm(g,m));
gmkt(g,"gd") = gd(g);
gmkt(g,"er") = er(g);
gmkt(g,"cs") = cs(g);
gmkt(g,"ch") = sum(h, ch(g,h));
gmkt(g,"chk") = gmkt(g,"ac") 
		+ gmkt(g,"mc") 
		+ gmkt(g,"tc") 
		+ gmkt(g,"rc") 
		- gmkt(g,"ca")
		- gmkt(g,"cm") 
		- gmkt(g,"gd") 
		- gmkt(g,"er") 
		- gmkt(g,"cs") 
		- gmkt(g,"ch");
display gmkt, tc;

*	3) Factor markets are similarly associated with a supply-demand balance
*	condition.  We extract the related submatrices and verify that
*	market clearance conditions are satisfied.

PARAMETER
                hf(h,f)        Factor income to households
                ef(f)	       Factor income to enterprise
                gf(f)          Factor income to government
                tf(t,f)        Factor taxes to government
                rf(f)          Factor remitance to rest of RoW

                dp(f)          Depreciation;

loop((maph(i,h), mapf(j,f)),         hf(h,f) = sam(i,j); sam(i,j)=0; );
loop((mape(i), mapf(j,f)),         ef(f) = sam(i,j); sam(i,j)=0; );
loop((mapt(i,t), mapf(j,f)),         tf(t,f) = sam(i,j); sam(i,j)=0; );
loop((mapx(i),   mapf(j,f)),         rf(f)   = sam(i,j); sam(i,j)=0; );
loop((mapi(i),   mapf(j,f)),         dp(f) = sam(i,j);	sam(i,j)=0; );
loop((mapg(i),   mapf(j,f)),         gf(f) = sam(i,j); sam(i,j)=0; );

parameter fmkt(f,*)	Factor market clearance;
fmkt(f,"fa") = sum(s, fa(f,s));
fmkt(f,"hf") = sum(h, hf(h,f));
fmkt(f,"ef") = sum(e, ef(f));
fmkt(f,"tf") = sum(t, tf(t,f));
fmkt(f,"rf") = rf(f);
fmkt(f,"dp") = dp(f);
fmkt(f,"gf") = gf(f);
fmkt(f,"chk") = fmkt(f,"fa") 
	- fmkt(f,"hf") 
	- fmkt(f,"ef") 
	- fmkt(f,"tf") 
	- fmkt(f,"rf") 
	- fmkt(f,"dp") 
	- fmkt(f,"gf");
display fmkt, tf;



*	4) Households are subject to budget constraints.  Here we extract
*	household-related data from the SAM and then verify that the budget
*	constraint is satisfied:

PARAMETER
	tp(t,h)        Income tax payment by households,
	he(h)		Enterprise payment to households,
	hg(h)          Government transfer to households,
	hr(h)          Household income from RoW,
	psv(h)         Private savings;

loop((mapt(i,t), maph(j,h)),	tp(t,h)= sam(i,j);	sam(i,j)=0;);
loop((maph(i,h), mape(j)),	he(h) = sam(i,j); sam(i,j)=0; );
loop((maph(i,h), mapg(j)),	hg(h)  = sam(i,j); sam(i,j)=0; );
loop((maph(i,h), mapx(j)),	hr(h)  = sam(i,j); sam(i,j)=0; );
loop((mapi(i), maph(j,h)),      psv(h) = sam(i,j); sam(i,j) = 0; );

parameter	hbudget(h,*)  Household budget;
				
hbudget(h,"hf") = sum(f, hf(h,f));
hbudget(h,"he") = he(h);
hbudget(h,"hg") = hg(h);
hbudget(h,"hr") = hr(h);

hbudget(h,"psv") = psv(h);
hbudget(h,"tp") = sum(t, tp(t,h));
hbudget(h,"ch") = sum(g,ch(g,h));
hbudget(h,"ha") = sum(s,ha(s,h));
				
hbudget(h,"chk") = hbudget(h,"hf") + hbudget(h,"he") + hbudget(h,"hg") + hbudget(h,"hr")
		- hbudget(h,"psv") - hbudget(h,"tp") - hbudget(h,"ch") - hbudget(h,"ha");
display hbudget, hg, hr;

*	5) Enterprises are likewise subject to a budget constraint.  Any
*	revenue from factor earnings is allocated to tax payments or transfers:

parameter
                te(t)        Enterprise direct taxes,
                ge           Enterprise dividend payment to government;

loop((mapt(i,t), mape(j)),         te(t) = sam(i,j); sam(i,j)=0; );
loop((mapg(i),   mape(j)),         ge   = sam(i,j); sam(i,j)=0; );

parameter	ebudget(*)	Enterprise budget;

ebudget("ef") = sum(f, ef(f));
ebudget("he") = sum(h,he(h));
ebudget("te") = sum(t, te(t));
ebudget("ge") = ge;
ebudget("chk") = ebudget("ef") 
		- ebudget("he")
		- ebudget("te")
		- ebudget("ge");
display ebudget, te;

*	6) Investment-savings balance asserts that someone is paying for any
*	investment which is being undertaken

parameter	gsv            Government savings
                fsv            Foreign savings;

loop((mapi(i), mapg(j)), gsv   = sam(i,j); sam(i,j)=0; );
loop((mapi(i), mapx(j)), fsv   = sam(i,j); sam(i,j)=0; );

parameter	invsave	Investment savings account;

invsave("cs") = sum(g, cs(g));
invsave("dp") = sum(f, dp(f));
invsave("gsv") = gsv;
invsave("fsv") = fsv;
invsave("psv") = sum(h, psv(h));
invsave("chk") = invsave("cs") - invsave("dp") - invsave("gsv") - invsave("fsv") - invsave("psv");
display invsave;

*	7) The public sector is likewise subject to a budget constraint:

parameter	tr(t)	Tax revenue;
loop((mapg(i),mapt(j,t)), tr(t) = sam(i,j); sam(i,j) = 0;);

parameter	gbudget	Government budget;
gbudget("gd") = sum(g, gd(g));
gbudget("gf") = sum(f, gf(f));
gbudget("hg") = sum(h, hg(h));
gbudget("ge") = ge;
gbudget("tr") = sum(t, tr(t));
gbudget("gsv") = gsv;
gbudget("chk") = gbudget("gd") + gbudget("hg") + gbudget("gsv")
		- gbudget("gf") - gbudget("ge") - gbudget("tr");
display gbudget;

*	8) Tax payments should equal tax revenue:

parameter taccount(t,*)	Tax revenue accounting;
taccount(t,"ta") = sum(s, ta(t,s));
taccount(t,"tc") = sum(g, tc(t,g));
taccount(t,"tf") = sum(f, tf(t,f));
taccount(t,"tp") = sum(h, tp(t,h));
taccount(t,"te") = sum(e, te(t));
taccount(t,"tr") = tr(t);
taccount(t,"chk") = taccount(t,"ta") + taccount(t,"tc") + taccount(t,"tf") + 
		    taccount(t,"tp") + taccount(t,"te") - taccount(t,"tr");
display taccount;

*	Verify that all the data have been extracted:

display "All values should be zero if all data has been read:", sam;


---- 109 SET negval Flag for negative elements (EMPTY) ---- 114 SET empty Flag for empty rows and columns row col 119 YES YES ---- 394 PARAMETER totals SAM totals for reporting A C M F E H G T X I A 12110.0 1949.0 C 6443.0 359.0 4951.0 516.0 1307.0 1319.0 M 353.0 F 7573.0 E 2268.0 H 5269.0 2171.0 62.0 403.0 G 1.0 669.0 T 19.0 432.0 18.0 95.0 93.0 X 2008.0 25.0 I 902.0 92.0 324.0 total 14035.0 14903.0 359.0 7580.0 2267.0 7895.0 670.0 669.0 2034.0 1319.0 + total A 14059.0 C 14895.0 M 353.0 F 7573.0 E 2268.0 H 7905.0 G 670.0 T 657.0 X 2033.0 I 1318.0 ---- 426 PARAMETER profit Zero profit check for sectors chk ac ha ta ca fa MAIZE 2.000 411.000 442.000 1.000 101.000 749.000 PADDY 337.000 69.000 124.000 282.000 SORGH -1.000 62.000 63.000 25.000 101.000 WHEAT 25.000 1.000 9.000 17.000 BEANS 155.000 54.000 32.000 177.000 CASSA 47.000 108.000 4.000 151.000 CEREA 30.000 4.000 8.000 26.000 OILSE -1.000 93.000 32.000 11.000 115.000 ROOTS 68.000 63.000 8.000 123.000 COTTO 2.000 96.000 47.000 47.000 COFFE 84.000 3.000 30.000 57.000 TOBAC 2.000 75.000 33.000 40.000 TEAGR 2.000 39.000 17.000 20.000 CASHE 87.000 9.000 78.000 SISAL 1.000 17.000 10.000 6.000 SUGAR -2.000 158.000 2.000 1.000 41.000 120.000 OFRVE 2.000 348.000 181.000 27.000 500.000 OCROP -2.000 39.000 26.000 6.000 61.000 LIVES -2.000 247.000 48.000 47.000 250.000 FISHI 323.000 10.000 31.000 302.000 HUFOR 5.000 169.000 134.000 21.000 277.000 MININ 2.000 128.000 17.000 109.000 MEATD 1.000 246.000 81.000 150.000 176.000 GRAIN 648.000 2.000 595.000 51.000 PFOOD -2.000 410.000 11.000 1.000 272.000 150.000 BEVER 166.000 6.000 107.000 65.000 CLOTH 2.000 412.000 1.000 180.000 229.000 WOODP 2.000 147.000 74.000 71.000 CHEMI 1.000 66.000 49.000 16.000 FERTI -1.000 11.000 9.000 3.000 PETRO 1.000 27.000 13.000 13.000 RUPLA 54.000 36.000 18.000 GLASS 2.000 89.000 57.000 30.000 METAL 2.000 133.000 91.000 40.000 EQUIP 1.000 115.000 67.000 47.000 UTILI 2.000 216.000 83.000 131.000 CONST 1.000 770.000 2.000 425.000 342.000 TRADE 1.000 1013.000 2.000 218.000 792.000 HOTEL 454.000 2.000 252.000 200.000 TRANS 685.000 2.000 244.000 439.000 ESTAT 2.000 1423.000 611.000 1.000 1578.000 453.000 ADMIN 1.000 1585.000 2.000 1112.000 470.000 PRIVS -2.000 402.000 2.000 173.000 229.000 ---- 426 PARAMETER ta Tax collection MAIZE SUGAR GRAIN PFOOD CLOTH CONST TRADE HOTEL TRANS ESTAT VATAX 1.000 1.000 2.000 1.000 1.000 2.000 2.000 2.000 2.000 1.000 + ADMIN PRIVS VATAX 2.000 2.000 ---- 474 PARAMETER gmkt Goods market clearance chk ac ca mc tc rc cm gd er cs MAIZE 411.000 283.000 28.000 1.000 16.000 1.000 PADDY -1.000 337.000 348.000 22.000 3.000 22.000 3.000 SORGH 4.000 62.000 46.000 5.000 WHEAT 25.000 44.000 3.000 1.000 19.000 BEANS 155.000 40.000 9.000 1.000 1.000 CASSA 47.000 7.000 5.000 3.000 CEREA 2.000 30.000 30.000 2.000 1.000 OILSE 1.000 93.000 29.000 11.000 4.000 ROOTS 1.000 68.000 13.000 5.000 4.000 COTTO 96.000 67.000 11.000 2.000 42.000 COFFE 84.000 6.000 11.000 7.000 95.000 TOBAC 75.000 37.000 9.000 1.000 48.000 TEAGR 39.000 2.000 4.000 9.000 26.000 CASHE -1.000 87.000 1.000 6.000 1.000 94.000 SISAL 17.000 18.000 1.000 SUGAR 1.000 158.000 214.000 13.000 15.000 50.000 13.000 OFRVE -2.000 348.000 34.000 40.000 8.000 28.000 OCROP 39.000 11.000 2.000 5.000 4.000 LIVES 247.000 155.000 11.000 7.000 3.000 6.000 FISHI 323.000 9.000 15.000 8.000 65.000 HUFOR 169.000 41.000 8.000 7.000 1.000 6.000 MININ 128.000 136.000 7.000 8.000 13.000 20.000 MEATD -2.000 246.000 1.000 5.000 39.000 4.000 1.000 GRAIN 1.000 648.000 25.000 21.000 4.000 16.000 7.000 PFOOD -1.000 410.000 14.000 14.000 46.000 74.000 7.000 BEVER -1.000 166.000 36.000 19.000 28.000 16.000 1.000 CLOTH 2.000 412.000 47.000 18.000 96.000 76.000 17.000 4.000 WOODP 2.000 147.000 160.000 6.000 12.000 68.000 6.000 28.000 CHEMI 3.000 66.000 34.000 5.000 37.000 112.000 3.000 FERTI 11.000 23.000 12.000 PETRO -3.000 27.000 71.000 11.000 8.000 242.000 RUPLA -1.000 54.000 32.000 2.000 15.000 61.000 1.000 30.000 GLASS -1.000 89.000 96.000 2.000 22.000 6.000 7.000 1.000 METAL 2.000 133.000 183.000 6.000 16.000 125.000 1.000 30.000 EQUIP 2.000 115.000 181.000 16.000 25.000 557.000 8.000 474.000 UTILI 216.000 151.000 CONST 1.000 770.000 297.000 2.000 474.000 TRADE -3.000 1013.000 429.000 359.000 228.000 HOTEL -2.000 454.000 175.000 TRANS -2.000 685.000 302.000 393.000 579.000 50.000 ESTAT 4.000 1423.000 1406.000 ADMIN 1.000 1585.000 960.000 17.000 516.000 71.000 PRIVS 1.000 402.000 249.000 95.000 142.000 + ch MAIZE 172.000 PADDY 34.000 SORGH 17.000 WHEAT 4.000 BEANS 124.000 CASSA 48.000 CEREA 1.000 OILSE 70.000 ROOTS 63.000 COFFE 1.000 TEAGR 24.000 SUGAR 8.000 OFRVE 336.000 OCROP 31.000 LIVES 107.000 FISHI 272.000 HUFOR 138.000 MEATD 294.000 GRAIN 656.000 PFOOD 524.000 BEVER 193.000 CLOTH 532.000 WOODP 37.000 CHEMI 180.000 PETRO 220.000 RUPLA 70.000 GLASS 16.000 METAL 64.000 EQUIP 48.000 UTILI 65.000 HOTEL 281.000 TRANS 149.000 ESTAT 13.000 ADMIN 54.000 PRIVS 105.000 ---- 474 PARAMETER tc Indirect taxes MAIZE PADDY WHEAT BEANS CASSA CEREA ROOTS COTTO COFFE TOBAC IMPTAX 1.000 3.000 1.000 INDTAX 1.000 3.000 1.000 4.000 2.000 7.000 1.000 + TEAGR CASHE SUGAR OCROP LIVES FISHI HUFOR MININ MEATD GRAIN IMPTAX 11.000 2.000 1.000 1.000 INDTAX 9.000 1.000 4.000 5.000 7.000 8.000 7.000 6.000 38.000 3.000 + PFOOD BEVER CLOTH WOODP CHEMI PETRO RUPLA GLASS METAL EQUIP IMPTAX 8.000 2.000 13.000 5.000 6.000 4.000 6.000 1.000 8.000 25.000 INDTAX 38.000 26.000 83.000 7.000 31.000 4.000 9.000 21.000 8.000 ---- 511 PARAMETER fmkt Factor market clearance chk fa hf ef tf rf FSUB 1.000 1949.000 1948.000 LCHILD 22.000 22.000 LNONF 69.000 69.000 LNFPF 1.000 83.000 82.000 LNFSF 1.000 531.000 530.000 LSECF -2.000 153.000 152.000 3.000 LNONM 1.000 83.000 82.000 LNFPM 265.000 265.000 LNFSM -4.000 677.000 681.000 LSECM -2.000 419.000 406.000 15.000 CAPAG 725.000 720.000 5.000 CAPNAG 2288.000 2268.000 20.000 LAND -3.000 309.000 312.000 ---- 511 PARAMETER tf Factor taxes to government LSECF LSECM FACTAX 3.000 15.000 ---- 546 PARAMETER hbudget Household budget chk ha ch hf he hg hr psv tp HRBFPL -5.000 159.000 220.000 385.000 12.000 4.000 24.000 3.000 HRFBPL 2.000 230.000 274.000 528.000 36.000 4.000 54.000 8.000 HRNOED 4.000 290.000 422.000 699.000 48.000 10.000 29.000 61.000 9.000 HRNFPS -1.000 305.000 519.000 804.000 34.000 9.000 26.000 47.000 3.000 HRNFSS -1.000 639.000 1335.000 1348.000 797.000 17.000 78.000 249.000 18.000 HRSECP 4.000 68.000 267.000 206.000 174.000 3.000 54.000 96.000 2.000 HUBFPL 3.000 12.000 75.000 39.000 53.000 1.000 3.000 HUFBPL 2.000 25.000 144.000 55.000 136.000 1.000 20.000 1.000 HUNOED 3.000 25.000 140.000 48.000 120.000 2.000 15.000 16.000 1.000 HUNFPS 31.000 210.000 126.000 124.000 2.000 16.000 24.000 3.000 HUNFSS -4.000 114.000 866.000 533.000 589.000 6.000 71.000 202.000 21.000 HUSECP 3.000 51.000 479.000 498.000 48.000 3.000 114.000 106.000 24.000 ---- 546 PARAMETER hg Government transfer to households HRBFPL 4.000, HRFBPL 4.000, HRNOED 10.000, HRNFPS 9.000, HRNFSS 17.000, HRSECP 3.000, HUBFPL 1.000 HUFBPL 1.000, HUNOED 2.000, HUNFPS 2.000, HUNFSS 6.000, HUSECP 3.000 ---- 546 PARAMETER hr Household income from RoW HRNOED 29.000, HRNFPS 26.000, HRNFSS 78.000, HRSECP 54.000, HUNOED 15.000, HUNFPS 16.000, HUNFSS 71.000 HUSECP 114.000 ---- 568 PARAMETER ebudget Enterprise budget chk 1.000, ef 2268.000, he 2171.000, te 95.000, ge 1.000 ---- 568 PARAMETER te Enterprise direct taxes DIRTAX 95.000 ---- 587 PARAMETER invsave Investment savings account chk 1.000, cs 1319.000, psv 902.000, gsv 92.000, fsv 324.000 ---- 603 PARAMETER gbudget Government budget gd 516.000, hg 62.000, ge 1.000, gsv 92.000, tr 669.000 ---- 616 PARAMETER taccount Tax revenue accounting chk ta tc tf tp te tr DIRTAX -2.000 93.000 95.000 190.000 IMPTAX -2.000 98.000 100.000 VATAX -5.000 19.000 24.000 INDTAX -3.000 334.000 337.000 FACTAX 18.000 18.000 ---- 620 All values should be zero if all data has been read: ---- 620 PARAMETER sam Base year social accounts ( ALL 0.000 )