Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

Re: st: Mata looping question

From   Maarten Buis <>
Subject   Re: st: Mata looping question
Date   Tue, 18 Oct 2011 11:54:36 +0200

On Tue, Oct 18, 2011 at 11:37 AM, Anna Reimondos wrote:
> For example if I have one original matrix called 'a'
> matrix a=(1,0,0\0,2,1\0,1,0\0,0,0)
> matrix list a
> I then want to create another matrix 'b' which is equal to 'a' but
> where every element has been shifted up one row and across one column.

I would not do that with a loop:

*------------- begin example ----------------
b = J(5,1,0), (a \ J(1,3,0))
*----------- end example ----------------
(For more on examples I sent to the Statalist see: )

Hope this helps,

Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index