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: doubt on Mata using multiple loops
From
Gioia de Melo <[email protected]>
To
[email protected]
Subject
st: doubt on Mata using multiple loops
Date
Sat, 13 Mar 2010 09:44:09 -0300
Hi,
I have problems linking two matrices with for and if.
Matrix X is of n*5, in the first column it identifies firms, columns 2:5
identify firms that are connected to firm in column 1. I need to create a
symmetric matrix A nxn that has 1 in cells between two firms that are
connected.
I run this program but it does not alter A although it does not point any
error:
mata
A=J(20,20,0)
X = st_data(.,.)
for (i=2;i<=cols(X);i++) {
for (j=1;j<=rows(X);j++){
for (i1=1;i1<=cols(A);i1++) {
for (j1=1;j1<=rows(A);j1++){
if (j1==j & i1== X[j,i]){
A[j1,i1]==1
}
}
}
}
}
end
Thank you for your help.
Gioia
*
* 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/