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

st: Making a Matrix from Three Variables

From   "Glenn Goldsmith" <>
To   <>
Subject   st: Making a Matrix from Three Variables
Date   Sat, 9 May 2009 17:44:51 +0100

Hi Allan,

It seems like what you're after is more-or-less the same as converting from
sparse matrix storage, so the mata code here should do the trick: 

You just need to get your variables into a mata matrix to start with and you
should be away:

  mata : st_view(x=.,.,("var2","var1","var3"))

NB: Note the inverted order of var1 and var2. This is because the code for
-sparse()- assumes that the first variable provides the row index, and the
second variable provides the column index.



Allan Joseph Medwick <> wrote:

Hi, All,

I have three variables (var1, var2, var3).  I would like to create a
matrix where the values of var1 are the columns (ascending), the
values of var2 are the rows (also ascending), and the values of var3
are the elements in the matrix.  I know there must be a user defined
procedure out there to do this, but I haven't been able to find it.


*   For searches and help try:

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