Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: matrix subscripting using loop


From   Thomas <[email protected]>
To   [email protected]
Subject   st: matrix subscripting using loop
Date   Wed, 15 Sep 2010 13:34:10 +0100

I would like to turn a 1 X 49 matrix into a 7 X 7 matrix using a loop.

I tried the following:

mat evi = J(7,7,0)

            forvalues r = 1(1)7{
                forvalues i = 1(7)43{
                    forvalues j = 7(7)49{

                        matrix evi[`r',1] = evimat[1,`i'..`j']
            }
            }
            }

it does not seem to work because it first loops over the first set of forvalues, then the second, etc.

But what I need is for it to loop over all three forvalue statements "at the same time". Any idea how to do this?

Then there might a an altogether different way of doing this...

Many thanks,

Thomas
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index