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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Converting a vetor into a matrix


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Converting a vetor into a matrix
Date   Mon, 24 Sep 2012 13:28:42 +0100

The error message does tell what you are doing wrong. Your vector is a
view, meaning a view of (some of) the data. You can't reshape it. It
makes no sense, as far as the Stata dataset is concerned, to ask to
change a vector of values in some observations into a matrix. You need
to copy the view to another vector first. Or use -st_data()- not
-st_view()- to define your vector.

Nick

On Mon, Sep 24, 2012 at 1:20 PM, André Gyllenram
<a_gyllenram@hotmail.com> wrote:
> Hello,
>
> I have read that in mata you can use rowshape or colshape to convert a vector into a matrix. But it does not seem to work for me. If I have a 9x1 vector and want to convert it to a 3*3 matrix how do I do that?
>
> If A is the 9x1 vector and I write:
>
> rowshape(A,3) i get this message:
>
>
> "rowshape():  3103  view found where array required
>                  <istmt>:     -  function returned error"
>
>
>
> Sorry if this has been asked before but i could not find it.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index