Dear all.
I'm trying to make mata program, but there are lots of things I do not know.
For example, I have a data set as below and then I use st_view or st_data to access the data set.
After access the dataset. The procedures that I wanna do are followings.
1. I would like to make a matrix(ex. saying matrix T) with the unique number of id1 rows and the unique number of id1 columns.
2. I would like to change the row names and column names of matrix T to id1.
3. After setting the T matrix, I would like to fill the matrix like, if T(1,3)=6, the x value when id1=1 and id3=3, and T(2.4) =67, the x value when id1=2 and id3==4.
I think I ask too many things.
But I really wanna learn how to handle mata command.
Thank you for reading this.
I'm trying to make mata program, but there are lots of things I do not know.
For example, I have a data set as below and then I use st_view or st_data to access the data set.
id1 | id2 | x |
1 | 2 | 5 |
1 | 3 | 6 |
1 | 4 | 8 |
2 | 1 | 18 |
2 | 3 | 4 |
2 | 4 | 67 |
3 | 1 | 0 |
3 | 2 | 12 |
3 | 4 | 54 |
4 | 1 | 6 |
4 | 2 | 86 |
4 | 3 | 9 |
1. I would like to make a matrix(ex. saying matrix T) with the unique number of id1 rows and the unique number of id1 columns.
2. I would like to change the row names and column names of matrix T to id1.
3. After setting the T matrix, I would like to fill the matrix like, if T(1,3)=6, the x value when id1=1 and id3=3, and T(2.4) =67, the x value when id1=2 and id3==4.
I think I ask too many things.
But I really wanna learn how to handle mata command.
Thank you for reading this.
Comment