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: Convert 3 variables to a matrix
From 
 
Eilya Torshizian <[email protected]> 
To 
 
"[email protected]" <[email protected]> 
Subject 
 
st: Convert 3 variables to a matrix 
Date 
 
Tue, 14 Jan 2014 00:10:53 +0000 
Dear Statalist members,
I need to convert three variables to a matrix. The values of variable A and B should be used as row and column names of the output matrix.  My variables are as follows,
A      B      C
A1 | A1 | C1
A1 | A2 | C2
A1 | A4 | C3
A1 | A5 | C4
A2 | A2 | C5
A2 | A1 | C6
A2 | A3 | C7
I need to convert these to the following matrix,
      A1 A2 A3 A4 A5
A1 C1 C2  0   C3  0
A2 C6 C5  C7  0   0
As I have wide range of observations, I would like to avoid nested loops.
Thanks,
Eilya.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/