Dear Forum,
I have a matrix with Leontief Coefficients with a size of 47x47. My aim is to merge the entries into a matrix with a size of 6x6.
I would love to know if a command exists that allows me to specify groups of entries and adding up the coefficients.
The code below shows how I started with the first two entries of the new matrix. A more elegant way would be to know commands that help me to add up all intersections of defined rows and columns. Any help would be highly appreciated.
Kind Regards
Stefan
I have a matrix with Leontief Coefficients with a size of 47x47. My aim is to merge the entries into a matrix with a size of 6x6.
I would love to know if a command exists that allows me to specify groups of entries and adding up the coefficients.
The code below shows how I started with the first two entries of the new matrix. A more elegant way would be to know commands that help me to add up all intersections of defined rows and columns. Any help would be highly appreciated.
Kind Regards
Stefan
Code:
import excel using "iotest.xlsx", firstrow; mkmat crop-other, matrix(A) rownames(Sectors) ; matrix B=J(6,6,0) ; matrix rownames B= food textile energy house transp misc ; matrix colnames B= food textile energy house transp misc ; matrix B[1,1]=A[1,1]+A[1,2]+A[1,7]+A[1,8]+A[2,1]+A[2,2]+A[2,7]+A[2,8]+A[7,1]+A[7,2]+A[7,7]+A[7,8]+A[8,1]+A[8,2]+A[8,7]+A[8,8]+A[9,9] ; matrix B[2,2]=A[10,10]+A[10,11]+A[10,12]+A[11,10]+A[11,11]+A[11,12]+A[12,10]+A[12,11]+A[12,12] ;
Comment