Help with matrix and loop

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Help with matrix and loop

jfca283
This post has NOT been accepted by the mailing list yet.
Hi
I hope you will understand my problem.
I wrote this code
matrix A=J(17,8,0)
forval i=1/17 {

forval j=0/7 {

quietly summarize var8 if branch== `i' & class== `j' [iw=expansion]
matrix A[`i' , `j'+1] = r(sum_w) 
}
}
The matrix A has 17 rows and 8 columns because branch starts from 1 to 17 and class from 0 to 8.
So, i'm storing the r(sum_w) for every match.
But know i need to expand the
quietly summarize var8 if branch== `i' & class== `j' [iw=expansion]
to
quietly summarize var8 if branch== `i' & class== `j' area=`iregion' [iw=expansion]
with area, a variable designing areas in numbers that goes from 1 to 15.
But i don't know how to store the values in the matrix.
I thought of generating 15 matrices names, and inserting a forval iregion=1/15, but i didn't work.
Can you guide me on this?
Thanks for your time and interest.