Dear Statalist
I would like to search a string "1" (stored as string) in the matrix transcribed to mata from stata. Moreover, I would like to search it row-wise and increment the column no. in the loop. The reason is that I would like to get the first row where "1" occurs (in any column).
The following is my code. Can I request your help in understanding what is the mistake here and how to get the desired output?
Thanks
Abhimanyu
I would like to search a string "1" (stored as string) in the matrix transcribed to mata from stata. Moreover, I would like to search it row-wise and increment the column no. in the loop. The reason is that I would like to get the first row where "1" occurs (in any column).
The following is my code. Can I request your help in understanding what is the mistake here and how to get the desired output?
Code:
mata x=st_sdata(.,.) for(i=1;i<=rows(x);i++){ for(j=1;j<=cols(x);j++){ if(x[i,j]=="1") break printf("i=%g\n",i) printf("j=%g\n",j) } } i j end
Thanks
Abhimanyu
Comment