* -------------- ANAR1 Macroeconomic Tables -------------------------------

* ------- 2. Assign Macroeconomic Tables ---------------------------------

* --- Macroeconomic Totals ---

* Value of household consumption
 nMACROTOT("stQCDTOT",r,clos,simr)
            = SUM((c,h),resPQD(c,r,clos,simr) * (1 + resTV(c,r,clos,simr))
                          * resQCD(c,h,r,clos,simr)) ;

* Value of government consumption
 nMACROTOT("stQGDTOT",r,clos,simr)
            = SUM(c,resPQD(c,r,clos,simr) * resQGD(c,r,clos,simr)) ;

* Value of investment consumption
 nMACROTOT("stQINVTOT",r,clos,simr)
            = SUM(c,resPQD(c,r,clos,simr) * resQINVD(c,r,clos,simr)) ;

* Value of Domestic final demand
 nMACROTOT("stQABSORP",r,clos,simr)
            = SUM((c,h),resPQD(c,r,clos,simr) * (1 + resTV(c,r,clos,simr))
                        * resQCD(c,h,r,clos,simr))
              + SUM(c,resPQD(c,r,clos,simr) * resQGD(c,r,clos,simr))
              + SUM(c,resPQD(c,r,clos,simr) * resQINVD(c,r,clos,simr)) ;

* Value of import demand
 nMACROTOT("stIMPORT",r,clos,simr)
            = SUM(c,resPM(c,r,clos,simr) * resQM(c,r,clos,simr)) ;

* Value of export supply
 nMACROTOT("stEXPORT",r,clos,simr)
            = SUM(c,resPE(c,r,clos,simr) * resQE(c,r,clos,simr)) ;

* GDP from Income side - total value added plus indirect taxes on prodn
 nMACROTOT("stGDPVA",r,clos,simr)
            = SUM((f,a),resWF(f,r,clos,simr) * resWFDIST(f,a,r,clos,simr)
                      * resFD(f,a,r,clos,simr))
                      + resITAX(r,clos,simr) ;

* GDP from Expenditure side - C + I + G + E - M
 nMACROTOT("stGDPEXP",r,clos,simr)
            = SUM((c,h),resPQD(c,r,clos,simr) * (1 + resTV(c,r,clos,simr))
                       * resQCD(c,h,r,clos,simr))
                + SUM(c,resPQD(c,r,clos,simr) * resQGD(c,r,clos,simr))
                + SUM(c,resPQD(c,r,clos,simr) * resQINVD(c,r,clos,simr))
                + SUM(c,resPE(c,r,clos,simr) * resQE(c,r,clos,simr))
                - SUM(c,resPM(c,r,clos,simr) * resQM(c,r,clos,simr)) ;

* total domestic production
 nMACROTOT("stSUPPLY",r,clos,simr)
            = SUM(c,resPXC(c,r,clos,simr)* resQXC(c,r,clos,simr)) ;

* total intermediate inputs
 nMACROTOT("stUSE",r,clos,simr)
            = SUM(c,resPQD(c,r,clos,simr)* resQINTD(c,r,clos,simr)) ;

* household income
 nMACROTOT("stYHTOT",r,clos,simr)
            = SUM(h,resYH(h,r,clos,simr)) ;

* government income
 nMACROTOT("stYGTOT",r,clos,simr)      = resYG(r,clos,simr) ;

* factor income
 nMACROTOT("stYFTOT",r,clos,simr)      = SUM(f,resYF(f,r,clos,simr)) ;

* distributed factor income
 nMACROTOT("stYFDISTTOT",r,clos,simr)  = SUM(f,resYFDIST(f,r,clos,simr)) ;

* Labour income
 nMACROTOT("stYFLABTOT",r,clos,simr)   = SUM(l,resYF(l,r,clos,simr)) ;

* total savings
 nMACROTOT("stTOTSAV",r,clos,simr)     = resTOTSAV(r,clos,simr) ;

* household savings
 nMACROTOT("stHOSAV",r,clos,simr)
            = SUM(h,resYH(h,r,clos,simr) * (1-resTYH(h,r,clos,simr))
                 * resSHH(h,r,clos,simr)) ;

* government savings
 nMACROTOT("stGOVSAV",r,clos,simr)     = resKAPGOV(r,clos,simr) ;

* foreign savings
 nMACROTOT("stFSAV",r,clos,simr)       = (resKAPWOR(r,clos,simr)*resER(r,clos,simr)) ;

* Depreciation
 nMACROTOT("stDEPREC",r,clos,simr)     = SUM(f,deprec(f,r)*resYF(f,r,clos,simr)) ;

* Import tariff revenue
 nMACROTOT("stMTAX",r,clos,simr)       = resMTAX(r,clos,simr) ;

* Export tax revenue
 nMACROTOT("stETAX",r,clos,simr)       = resETAX(r,clos,simr) ;

* Sales tax revenue
 nMACROTOT("stSTAX",r,clos,simr)       = resSTAX(r,clos,simr) ;

* Indirect tax revenue
 nMACROTOT("stITAX",r,clos,simr)       = resITAX(r,clos,simr) ;

* Factor tax revenu
 nMACROTOT("stFTAX",r,clos,simr)       = resFTAX(r,clos,simr) ;

* Household income tax revenue
 nMACROTOT("stHTAX",r,clos,simr)       = resHTAX(r,clos,simr) ;

* --- Macroeconomic Shares ---

* Share of household consumption in GDPEXP
 nMACROSH1("stQCDTOT",r,clos,simr)$nMACROTOT("stGDPEXP",r,clos,simr)
           = SUM((c,h),resPQD(c,r,clos,simr) * (1 + resTV(c,r,clos,simr))
                   * resQCD(c,h,r,clos,simr))
                                /nMACROTOT("stGDPEXP",r,clos,simr) ;

* Share of government consumption in GDPEXP
 nMACROSH1("stQGDTOT",r,clos,simr)$nMACROTOT("stGDPEXP",r,clos,simr)
            = SUM(c,resPQD(c,r,clos,simr) * resQGD(c,r,clos,simr))
                                /nMACROTOT("stGDPEXP",r,clos,simr) ;

* Share of investment consumption in GDPEXP
 nMACROSH1("stQINVTOT",r,clos,simr)$nMACROTOT("stGDPEXP",r,clos,simr)
            = SUM(c,resPQD(c,r,clos,simr) * resQINVD(c,r,clos,simr))
                                /nMACROTOT("stGDPEXP",r,clos,simr) ;

* Ratio of import demand to GDPEXP
 nMACROSH1("stIMPORT",r,clos,simr)$nMACROTOT("stGDPEXP",r,clos,simr)
            = SUM(c,resPM(c,r,clos,simr) * resQM(c,r,clos,simr))
                                /nMACROTOT("stGDPEXP",r,clos,simr) ;

* Ratio of export supply to GDPEXP
 nMACROSH1("stEXPORT",r,clos,simr)$nMACROTOT("stGDPEXP",r,clos,simr)
            = SUM(c,resPE(c,r,clos,simr) * resQE(c,r,clos,simr))
                                /nMACROTOT("stGDPEXP",r,clos,simr) ;

* Share of household consumption in ABSORP
 nMACROSH2("stQCDTOT",r,clos,simr)$nMACROTOT("stQABSORP",r,clos,simr)
            = SUM((c,h),resPQD(c,r,clos,simr) * (1 + resTV(c,r,clos,simr))
                         * resQCD(c,h,r,clos,simr))
                                /nMACROTOT("stQABSORP",r,clos,simr) ;

* Share of government consumption in ABSORP
 nMACROSH2("stQGDTOT",r,clos,simr)$nMACROTOT("stQABSORP",r,clos,simr)
            = SUM(c,resPQD(c,r,clos,simr) * resQGD(c,r,clos,simr))
                                /nMACROTOT("stQABSORP",r,clos,simr) ;

* Share of investment consumption in ABSORP
 nMACROSH2("stQINVTOT",r,clos,simr)$nMACROTOT("stQABSORP",r,clos,simr)
            = SUM(c,resPQD(c,r,clos,simr) * resQINVD(c,r,clos,simr))
                                /nMACROTOT("stQABSORP",r,clos,simr) ;

* Ration of import demand consumption to ABSORP
 nMACROSH2("stIMPORT",r,clos,simr)$nMACROTOT("stQABSORP",r,clos,simr)
            = SUM(c,resPM(c,r,clos,simr) * resQM(c,r,clos,simr))
                                /nMACROTOT("stQABSORP",r,clos,simr) ;

* Ratio of export supply to ABSORP
 nMACROSH2("stEXPORT",r,clos,simr)$nMACROTOT("stQABSORP",r,clos,simr)
            = SUM(c,resPE(c,r,clos,simr) * resQE(c,r,clos,simr))
                                /nMACROTOT("stQABSORP",r,clos,simr) ;

* --- Scenario Result: Real Macroeconomic totals - levels

* Value of household consumption
 rMACROTOT("stQCDTOT",r,clos,simr)
            = SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * resQCD(c,h,r,clos,simr)) ;

* Value of government consumption
 rMACROTOT("stQGDTOT",r,clos,simr)
            = SUM(c,PQD0(c,r) * resQGD(c,r,clos,simr)) ;

* Value of investment consumption
 rMACROTOT("stQINVTOT",r,clos,simr)
            = SUM(c,PQD0(c,r) * resQINVD(c,r,clos,simr)) ;

* Value of Domestic final demand
 rMACROTOT("stQABSORP",r,clos,simr)
            = SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * resQCD(c,h,r,clos,simr))
              + SUM(c,PQD0(c,r) * resQGD(c,r,clos,simr))
              + SUM(c,PQD0(c,r) * resQINVD(c,r,clos,simr)) ;

* Value of import demand
 rMACROTOT("stIMPORT",r,clos,simr)
            = SUM(c,PM0(c,r) * resQM(c,r,clos,simr)) ;

* Value of export supply
 rMACROTOT("stEXPORT",r,clos,simr)
            = SUM(c,PE0(c,r) * resQE(c,r,clos,simr)) ;

* GDP from Income side - total value added plus indirect taxes on prodn
 rMACROTOT("stGDPVA",r,clos,simr)
            = SUM((f,a),WF0(f,r) * WFDIST0(f,a,r)
                      * resFD(f,a,r,clos,simr))
                      + resITAX(r,clos,simr) ;

* GDP from Expenditure side - C + I + G + E - M
 rMACROTOT("stGDPEXP",r,clos,simr)
            = SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * resQCD(c,h,r,clos,simr))
                + SUM(c,PQD0(c,r) * resQGD(c,r,clos,simr))
                + SUM(c,PQD0(c,r) * resQINVD(c,r,clos,simr))
                + SUM(c,PE0(c,r) * resQE(c,r,clos,simr))
                - SUM(c,PM0(c,r) * resQM(c,r,clos,simr)) ;

* total domestic production
 rMACROTOT("stSUPPLY",r,clos,simr)
            = SUM(c,PXC0(c,r)* resQXC(c,r,clos,simr)) ;

* total intermediate inputs
 rMACROTOT("stUSE",r,clos,simr)
            = SUM(c,PQD0(c,r)* resQINTD(c,r,clos,simr)) ;


* --- Real Macroeconomic totals - percentage changes

* Real value of household consumption
 rperMACROTOT("stQCDTOT",r,clos,simr)$SUM((c,h),PQD0(c,r) * (1 + TV0(c,r))
                                             * QCD0(c,h,r))
            = (SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * resQCD(c,h,r,clos,simr))
                  /SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * QCD0(c,h,r)) - 1) * 100 ;

* Real value of government consumption
 rperMACROTOT("stQGDTOT",r,clos,simr)$SUM(c,PQD0(c,r) * QGD0(c,r))
            = (SUM(c,PQD0(c,r) * resQGD(c,r,clos,simr))
                  /SUM(c,PQD0(c,r) * QGD0(c,r)) - 1) * 100 ;

* Real value of investment consumption
 rperMACROTOT("stQINVTOT",r,clos,simr)$SUM(c,PQD0(c,r) * QINVD0(c,r))
            = (SUM(c,PQD0(c,r) * resQINVD(c,r,clos,simr))
                  /SUM(c,PQD0(c,r) * QINVD0(c,r)) - 1) * 100 ;

* Real value of Domestic final demand
 rperMACROTOT("stQABSORP",r,clos,simr)$(SUM((c,h),PQD0(c,r) * (1 + TV0(c,r))
                                           * QCD0(c,h,r))
                         + SUM(c,PQD0(c,r) * QGD0(c,r))
                         + SUM(c,PQD0(c,r) * QINVD0(c,r)))
                       = ((SUM((c,h),PQD0(c,r) * (1 + TV0(c,r))
                             * resQCD(c,h,r,clos,simr))
                         + SUM(c,PQD0(c,r) * resQGD(c,r,clos,simr))
                         + SUM(c,PQD0(c,r) * resQINVD(c,r,clos,simr)))
                         / (SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * QCD0(c,h,r))
                         + SUM(c,PQD0(c,r) * QGD0(c,r))
                         + SUM(c,PQD0(c,r) * QINVD0(c,r))) - 1) * 100 ;

* Real value of import demand
 rperMACROTOT("stIMPORT",r,clos,simr)$SUM(c,PM0(c,r) * QM0(c,r))
                      = (SUM(c,PM0(c,r) * resQM(c,r,clos,simr))
                         /SUM(c,PM0(c,r) * QM0(c,r)) - 1) * 100 ;

* Real value of export supply
 rperMACROTOT("stEXPORT",r,clos,simr)$SUM(c,PE0(c,r) * QE0(c,r))
                      = (SUM(c,PE0(c,r) * resQE(c,r,clos,simr))
                         /SUM(c,PE0(c,r) * QE0(c,r)) - 1) * 100 ;

* Real GDP from Income side - total value added plus indirect taxes on prodn
 rperMACROTOT("stGDPVA",r,clos,simr)$(SUM((f,a),WF0(f,r) * WFDIST0(f,a,r) * FD0(f,a,r))
                           + ITAX0(r))
                      = ((SUM((f,a),WF0(f,r) * WFDIST0(f,a,r) * resFD(f,a,r,clos,simr))
                        + resITAX(r,clos,simr))
                          /(SUM((f,a),WF0(f,r) * WFDIST0(f,a,r) * FD0(f,a,r))
                           + ITAX0(r)) - 1) * 100 ;

* Real GDP from Expenditure side - C + I + G + E - M
 rperMACROTOT("stGDPEXP",r,clos,simr)$(SUM((c,h),PQD0(c,r) * (1 + TV0(c,r))
                                             * QCD0(c,h,r))
                           + SUM(c,PQD0(c,r) * QGD0(c,r))
                           + SUM(c,PQD0(c,r) * QINVD0(c,r))
                           + SUM(c,PE0(c,r) * QE0(c,r))
                           - SUM(c,PM0(c,r) * QM0(c,r)))
                      = ((SUM((c,h),PQD0(c,r) * (1 + TV0(c,r))
                                  * resQCD(c,h,r,clos,simr))
                        + SUM(c,PQD0(c,r) * resQGD(c,r,clos,simr))
                        + SUM(c,PQD0(c,r) * resQINVD(c,r,clos,simr))
                        + SUM(c,PE0(c,r) * resQE(c,r,clos,simr))
                        - SUM(c,PM0(c,r) * resQM(c,r,clos,simr)))
                          /(SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * QCD0(c,h,r))
                           + SUM(c,PQD0(c,r) * QGD0(c,r))
                           + SUM(c,PQD0(c,r) * QINVD0(c,r))
                           + SUM(c,PE0(c,r) * QE0(c,r))
                           - SUM(c,PM0(c,r) * QM0(c,r))) - 1) * 100 ;

* total domestic production
 rperMACROTOT("stSUPPLY",r,clos,simr)$(SUM(c,PXC0(c,r)* QXC0(c,r)))
            = ((SUM(c,PXC0(c,r)* resQXC(c,r,clos,simr)))
                /(SUM(c,PXC0(c,r)* QXC0(c,r))) - 1) * 100 ;

* total intermediate inputs
 rperMACROTOT("stUSE",r,clos,simr)$(SUM(c,PQD0(c,r)* QINTD0(c,r)))
            = ((SUM(c,PQD0(c,r)* resQINTD(c,r,clos,simr)))
                /(SUM(c,PQD0(c,r)* QINTD0(c,r))) - 1) * 100 ;

* --- Nominal Macroeconomic Totals - Percentage Changes ---

* Value of household consumption
 nperMACROTOT("stQCDTOT",r,clos,simr)$SUM((c,h),PQD0(c,r) * (1 + TV0(c,r))
                                                   * QCD0(c,h,r))
            = (SUM((c,h),resPQD(c,r,clos,simr) * (1 + resTV(c,r,clos,simr))
                       * resQCD(c,h,r,clos,simr))
               /SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * QCD0(c,h,r)) - 1) * 100 ;

* Value of government consumption
 nperMACROTOT("stQGDTOT",r,clos,simr)$SUM(c,PQD0(c,r) * QGD0(c,r))
            = (SUM(c,resPQD(c,r,clos,simr) * resQGD(c,r,clos,simr))
               /SUM(c,PQD0(c,r) * QGD0(c,r)) - 1) * 100 ;

* Value of investment consumption
 nperMACROTOT("stQINVTOT",r,clos,simr)$SUM(c,PQD0(c,r) * QINVD0(c,r))
            = (SUM(c,resPQD(c,r,clos,simr) * resQINVD(c,r,clos,simr))
               /SUM(c,PQD0(c,r) * QINVD0(c,r)) - 1) * 100 ;

* Value of Domestic final demand
 nperMACROTOT("stQABSORP",r,clos,simr)$(SUM((c,h),PQD0(c,r) * (1 + TV0(c,r))
                                                  * QCD0(c,h,r))
                                       + SUM(c,PQD0(c,r) * QGD0(c,r))
                                       + SUM(c,PQD0(c,r) * QINVD0(c,r)))
            = ((SUM((c,h),resPQD(c,r,clos,simr) * (1 + resTV(c,r,clos,simr))
                         * resQCD(c,h,r,clos,simr))
              + SUM(c,resPQD(c,r,clos,simr) * resQGD(c,r,clos,simr))
              + SUM(c,resPQD(c,r,clos,simr) * resQINVD(c,r,clos,simr)))
                / (SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * QCD0(c,h,r))
                   + SUM(c,PQD0(c,r) * QGD0(c,r))
                   + SUM(c,PQD0(c,r) * QINVD0(c,r))) - 1) * 100 ;

* Value of import demand
 nperMACROTOT("stIMPORT",r,clos,simr)$SUM(c,PM0(c,r) * QM0(c,r))
            = (SUM(c,resPM(c,r,clos,simr) * resQM(c,r,clos,simr))
               /SUM(c,PM0(c,r) * QM0(c,r)) - 1) * 100 ;

* Value of export supply
 nperMACROTOT("stEXPORT",r,clos,simr)$SUM(c,PE0(c,r) * QE0(c,r))
            = (SUM(c,resPE(c,r,clos,simr) * resQE(c,r,clos,simr))
               /SUM(c,PE0(c,r) * QE0(c,r)) - 1) * 100 ;

* GDP from Income side - total value added plus indirect taxes on prodn
 nperMACROTOT("stGDPVA",r,clos,simr)$(SUM((f,a),WF0(f,r) * WFDIST0(f,a,r)
                                    * FD0(f,a,r)) + ITAX0(r))
            = ((SUM((f,a),resWF(f,r,clos,simr) * resWFDIST(f,a,r,clos,simr)
                      * resFD(f,a,r,clos,simr))
                      + resITAX(r,clos,simr))
                        /(SUM((f,a),WF0(f,r) * WFDIST0(f,a,r) * FD0(f,a,r))
                            + ITAX0(r)) - 1) * 100 ;

* GDP from Expenditure side - C + I + G + E - M
 nperMACROTOT("stGDPEXP",r,clos,simr)$(SUM((c,h),PQD0(c,r) * (1 + TV0(c,r))
                                                 * QCD0(c,h,r))
                                       + SUM(c,PQD0(c,r) * QGD0(c,r))
                                       + SUM(c,PQD0(c,r) * QINVD0(c,r))
                                       + SUM(c,PE0(c,r) * QE0(c,r))
                                       - SUM(c,PM0(c,r) * QM0(c,r)))
            = ((SUM((c,h),resPQD(c,r,clos,simr) * (1 + resTV(c,r,clos,simr))
                         * resQCD(c,h,r,clos,simr))
                + SUM(c,resPQD(c,r,clos,simr) * resQGD(c,r,clos,simr))
                + SUM(c,resPQD(c,r,clos,simr) * resQINVD(c,r,clos,simr))
                + SUM(c,resPE(c,r,clos,simr) * resQE(c,r,clos,simr))
                - SUM(c,resPM(c,r,clos,simr) * resQM(c,r,clos,simr)))
                          /(SUM((c,h),PQD0(c,r) * (1 + TV0(c,r)) * QCD0(c,h,r))
                           + SUM(c,PQD0(c,r) * QGD0(c,r))
                           + SUM(c,PQD0(c,r) * QINVD0(c,r))
                           + SUM(c,PE0(c,r) * QE0(c,r))
                           - SUM(c,PM0(c,r) * QM0(c,r))) - 1) * 100 ;

* total domestic production
 nperMACROTOT("stSUPPLY",r,clos,simr)$(SUM(c,PXC0(c,r)* QXC0(c,r)))
            = (SUM(c,resPXC(c,r,clos,simr)* resQXC(c,r,clos,simr))
                /(SUM(c,PXC0(c,r)* QXC0(c,r))) - 1) * 100 ;

* total intermediate inputs
 nperMACROTOT("stUSE",r,clos,simr)$(SUM(c,PQD0(c,r)* QINTD0(c,r)))
            = (SUM(c,resPQD(c,r,clos,simr)* resQINTD(c,r,clos,simr))
                /(SUM(c,PQD0(c,r)* QINTD0(c,r))) - 1) * 100 ;

* household income
 nperMACROTOT("stYHTOT",r,clos,simr)$(SUM(h,YH0(h,r)))
            = (SUM(h,resYH(h,r,clos,simr))
               /(SUM(h,YH0(h,r))) - 1) * 100 ;

* government income
 nperMACROTOT("stYGTOT",r,clos,simr)$(YG0(r))
            = (resYG(r,clos,simr)
              /(YG0(r)) - 1) * 100 ;

* factor income
 nperMACROTOT("stYFTOT",r,clos,simr)$(SUM(f,YF0(f,r)))
            = (SUM(f,resYF(f,r,clos,simr))
               /(SUM(f,YF0(f,r))) - 1) * 100 ;

* distributed factor income
 nperMACROTOT("stYFDISTTOT",r,clos,simr)$(SUM(f,YFDIST0(f,r)))
            = (SUM(f,resYFDIST(f,r,clos,simr))
               /(SUM(f,YFDIST0(f,r))) - 1) * 100 ;

* Labour income
 nperMACROTOT("stYFLABTOT",r,clos,simr)$(SUM(l,YF0(l,r)))
            = (SUM(l,resYF(l,r,clos,simr))
               /(SUM(l,YF0(l,r))) - 1) * 100 ;

* total savings
 nperMACROTOT("stTOTSAV",r,clos,simr)$(TOTSAV0(r))
            = (resTOTSAV(r,clos,simr)
               /(TOTSAV0(r)) - 1) * 100 ;

* household savings
 nperMACROTOT("stHOSAV",r,clos,simr)$(SUM(h,YH0(h,r) * (1-TYH0(h,r))
                                    * SHH0(h,r)))
            = (SUM(h,resYH(h,r,clos,simr) * (1-resTYH(h,r,clos,simr))
                 * resSHH(h,r,clos,simr))
                    /(SUM(h,YH0(h,r) * (1-TYH0(h,r))
                      * SHH0(h,r))) - 1) * 100 ;

* government savings
 nperMACROTOT("stGOVSAV",r,clos,simr)$(KAPGOV0(r))
            = (resKAPGOV(r,clos,simr)
               /(KAPGOV0(r)) - 1) * 100 ;

* foreign savings
 nperMACROTOT("stFSAV",r,clos,simr)$(KAPWOR0(r)*ER0(r))
            = ((resKAPWOR(r,clos,simr)*resER(r,clos,simr))
                /(KAPWOR0(r)*ER0(r)) - 1) * 100 ;

* Depreciation
 nperMACROTOT("stDEPREC",r,clos,simr)$(SUM(f,deprec(f,r)*YF0(f,r)))
            = (SUM(f,deprec(f,r)*resYF(f,r,clos,simr))
               /(SUM(f,deprec(f,r)*YF0(f,r))) - 1) * 100 ;

* Import tariff revenue
 nperMACROTOT("stMTAX",r,clos,simr)$MTAX0(r)
            = (resMTAX(r,clos,simr)/(MTAX0(r)) - 1) * 100 ;

* Export tax revenue
 nperMACROTOT("stETAX",r,clos,simr)$ETAX0(r)
            = (resETAX(r,clos,simr)/(ETAX0(r)) - 1) * 100 ;

* Sales tax revenue
 nperMACROTOT("stSTAX",r,clos,simr)$STAX0(r)
            = (resSTAX(r,clos,simr)/(STAX0(r)) - 1) * 100 ;

* Indirect tax revenue
 nperMACROTOT("stITAX",r,clos,simr)$ITAX0(r)
            = (resITAX(r,clos,simr)/(ITAX0(r)) - 1) * 100 ;

* Factor tax revenu
 nperMACROTOT("stFTAX",r,clos,simr)$FTAX0(r)
            = (resFTAX(r,clos,simr)/(FTAX0(r)) - 1) * 100 ;

* Household income tax revenue
 nperMACROTOT("stHTAX",r,clos,simr)$HTAX0(r)
            = (resHTAX(r,clos,simr)/(HTAX0(r)) - 1) * 100 ;


* ------- Exporting Macroeconomic Tables to GDX -----------------------------

* This writes the results data to GDX

Execute_Unload  'results/anar1_resmacro.gdx',

                          nMACROTOT,
                          nMACROSH1,
                          nMACROSH2,
                          rMACROTOT,
                          rperMACROTOT,
                          nperMACROTOT

   ;

* -------------- End of anar1 Macroeconomic Tables ------------------------