Hey,

I have a dataset of around 50 vars and 30k obsevations. I have created a matrix that stores revenue information of different groups per day (Ex. dataset below to help visualise) The problem is that the matrix stores the day and group of the matrix in the row.
Is it possible to rearrange the matrix so that it creates a matrix m*n where m are the different groups and n are different days, and the entries are revenue. I have been working with this problem for quite a while and haven't been able to solve it. The solution that I have almost works but not quite because I can't access the day and group of the entries (and thus cannot conduct analysis)

Code:
 c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@
    1.dayOfMonth#  1.dayOfMonth#  1.dayOfMonth#  1.dayOfMonth#  1.dayOfMonth#  1.dayOfMonth#  1.dayOfMonth#  1.dayOfMonth#
    1.target_g~d   2.target_g~d   3.target_g~d   4.target_g~d   5.target_g~d   6.target_g~d   7.target_g~d   8.target_g~d
b          20674          13567          13130           7886          17429          13902          10893          29666

      c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@
    1.dayOfMonth#  1.dayOfMonth#  2.dayOfMonth#  2.dayOfMonth#  2.dayOfMonth#  2.dayOfMonth#  2.dayOfMonth#  2.dayOfMonth#
    9.target_g~d   10.target_~d   1.target_g~d   2.target_g~d   3.target_g~d   4.target_g~d   5.target_g~d   6.target_g~d
b           9065          34015          22894          17047          11682           7741          16816          10470

      c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@
    2.dayOfMonth#  2.dayOfMonth#  2.dayOfMonth#  2.dayOfMonth#  3.dayOfMonth#  3.dayOfMonth#  3.dayOfMonth#  3.dayOfMonth#
    7.target_g~d   8.target_g~d   9.target_g~d   10.target_~d   1.target_g~d   2.target_g~d   3.target_g~d   4.target_g~d
b          11471          38628          11053          33128          23616          16712          12436           8017

      c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@
    3.dayOfMonth#  3.dayOfMonth#  3.dayOfMonth#  3.dayOfMonth#  3.dayOfMonth#  3.dayOfMonth#  4.dayOfMonth#  4.dayOfMonth#
    5.target_g~d   6.target_g~d   7.target_g~d   8.target_g~d   9.target_g~d   10.target_~d   1.target_g~d   2.target_g~d
b          16937           9579          12846          38089          13003          31822          25709          19998

      c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@
    4.dayOfMonth#  4.dayOfMonth#  4.dayOfMonth#  4.dayOfMonth#  4.dayOfMonth#  4.dayOfMonth#  4.dayOfMonth#  4.dayOfMonth#
    3.target_g~d   4.target_g~d   5.target_g~d   6.target_g~d   7.target_g~d   8.target_g~d   9.target_g~d   10.target_~d
b          16059          10336          22089          12394          18866          43933          16182          36637

      c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@    c.installs@
    5.dayOfMonth#  5.dayOfMonth#  5.dayOfMonth#  5.dayOfMonth#  5.dayOfMonth#  5.dayOfMonth#  5.dayOfMonth#  5.dayOfMonth#
    1.target_g~d   2.target_g~d   3.target_g~d   4.target_g~d   5.target_g~d   6.target_g~d   7.target_g~d   8.target_g~d
b          21699          16640          15535           8825          18284          11347          16363          35506
Ideally, I would have a matrix that looks something like this
Code:
 day    group    K    L    M    N    O    P    Q    R    S    T
1    7793401    723627    1033846    687125    363888    547267    606642    662351    1390509    575549    1202597
2    9646816    665792    2489719    445140    333082    481752    418506    671434    1602947    1418433    1120011
3    9836604    733971    2345679    529144    330556    515295    412252    842270    1694316    1337551    1095570
And the code that I have written so far.
Code:
    //country_encoded cols...
total ad_impressions, over(country_encoded dayOfMonth)
matrix temp = r(table)
matrix impressionPerCountryAndDay = temp[1, 1..(colsof(temp))]
The time variable DayOfMonth goes from 1 to 31


Thank you in advance for helping.