Dear all,
What I am trying to do is create a numeric matrix from, let's say, 3
string variables. My data set provides information about companies
that have cooperative agreements between them. Thus each string
variable consists of the company codes (which are alphanumeric) of the
partners in the agreements; the first column always contain a
participant code (no empty cell); remaining columns feature other
participants, and may contain a code or may be empty (depending on
whether or not the the participant in the first column has a
cooperative agreement with one or more firms) My aim is to transform
this data into an a numeric matrix (N x N, where N is the total number
of firms) in which the elements represent the number of agreements
between firms (a value greater than zero indicates the presence of a
cooperative agreement between two firms and 0 indicates its absence).
(Perhaps I first need to create a string matrix (N x N) with the
elements of the matrix being the company codes; but I have been unable
to do this). I am not very familiar with the matrix-based features of
Stata, but was wondering if Mata could help solve this ?
The following example illustrates what I've in mind :
1. Current data (each cell indicates a company code, and each row
represents a cooperative agreement)
partner1 partner2 partner3
11A --- 12Z
12Z 21S 11K
14T 11A 12Z
2. Final numeric matrix (row and column labels indicate company codes)
11A 12Z 21S 11K 14T
11A 0 2 0 0 1
12Z 2 0 1 1 1
21S 0 1 0 1 0
11K 0 1 1 0 0
14T 1 1 0 0 0
Kind regards,
Joe
*
* 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/