Hello, new STATA learner here
I have a sample of my data and I try to sort it based on date. but I can`t figure out the code.
this is a sample of my dataset:
Date Companies Return MarketCap PBR t
31 Dec 2018 Comp1 -.0753 2.310e+08 1.095 1
31 Dec 2018 Comp2 -.1307 44044143 .89241 2
31 Dec 2018 Comp3 -.0356 20107234 3.07592 3
31 Dec 2018 Comp4 .1555 25572773 6.154 4
31 Dec 2018 Comp5 .0043 24495543 1.55772 5
31 Dec 2018 Comp6 .0605 15059432 1.25528 6
31 Dec 2018 Comp7 .1075 25319680 .47472 7
31 Dec 2018 Comp8 -.0845 8588941 1.67169 8
31 Dec 2018 Comp9 .1049 13660745 .49748 9
31 Dec 2018 Comp10 -.0148 19442186 .53016 10
31 Dec 2018 Comp11 -.0182 21186401 .47182 11
31 Dec 2018 Comp12 .0526 18495334 .59724 12
31 Dec 2018 Comp13 -.0544 28468515 10.56176 13
31 Dec 2018 Comp14 -.1407 10195259 .78793 14
31 Dec 2018 Comp15 -.0865 16597569 .87337 15
31 Dec 2018 Comp16 -.0388 18778304 .52334 16
31 Dec 2018 Comp17 .0293 20012300 .92337 17
31 Dec 2018 Comp18 -.0764 18293677 1.05184 18
31 Dec 2018 Comp19 -.0509 17195635 5.44452 19
31 Dec 2018 Comp20 -.0359 10883775 .41181 20
31 Jan 2019 Comp1 .1925 2.755e+08 1.22975 21
31 Jan 2019 Comp2 .2215 53799375 1.06682 22
31 Jan 2019 Comp3 .1148 22414622 3.11504 23
31 Jan 2019 Comp4 .0323 26399835 6.06272 24
31 Jan 2019 Comp5 .0605 25977982 1.65942 25
31 Jan 2019 Comp6 .0205 15368872 1.24155 26
31 Jan 2019 Comp7 .0928 27670030 .50101 27
31 Jan 2019 Comp8 -.0359 8280406 1.63821 28
31 Jan 2019 Comp9 .0786 14734958 .50472 29
I have 20 companies and 37 dates (Only showing 2). I`m trying to sort Marketcap and PBR by each date, for example, 31/12/2018, 31/01/2019, and so on. after sorting market cap, for example, I want to get the correspondent return for the sorted market cap and get the average of smalls, and the average of bigs and then the average of these 2. and I want to do the same thing to PBR.
could you help me figure out the right code for this.
I later have to use a bigger dataset, more than 2000 comps.
thank you
I have a sample of my data and I try to sort it based on date. but I can`t figure out the code.
this is a sample of my dataset:
Date Companies Return MarketCap PBR t
31 Dec 2018 Comp1 -.0753 2.310e+08 1.095 1
31 Dec 2018 Comp2 -.1307 44044143 .89241 2
31 Dec 2018 Comp3 -.0356 20107234 3.07592 3
31 Dec 2018 Comp4 .1555 25572773 6.154 4
31 Dec 2018 Comp5 .0043 24495543 1.55772 5
31 Dec 2018 Comp6 .0605 15059432 1.25528 6
31 Dec 2018 Comp7 .1075 25319680 .47472 7
31 Dec 2018 Comp8 -.0845 8588941 1.67169 8
31 Dec 2018 Comp9 .1049 13660745 .49748 9
31 Dec 2018 Comp10 -.0148 19442186 .53016 10
31 Dec 2018 Comp11 -.0182 21186401 .47182 11
31 Dec 2018 Comp12 .0526 18495334 .59724 12
31 Dec 2018 Comp13 -.0544 28468515 10.56176 13
31 Dec 2018 Comp14 -.1407 10195259 .78793 14
31 Dec 2018 Comp15 -.0865 16597569 .87337 15
31 Dec 2018 Comp16 -.0388 18778304 .52334 16
31 Dec 2018 Comp17 .0293 20012300 .92337 17
31 Dec 2018 Comp18 -.0764 18293677 1.05184 18
31 Dec 2018 Comp19 -.0509 17195635 5.44452 19
31 Dec 2018 Comp20 -.0359 10883775 .41181 20
31 Jan 2019 Comp1 .1925 2.755e+08 1.22975 21
31 Jan 2019 Comp2 .2215 53799375 1.06682 22
31 Jan 2019 Comp3 .1148 22414622 3.11504 23
31 Jan 2019 Comp4 .0323 26399835 6.06272 24
31 Jan 2019 Comp5 .0605 25977982 1.65942 25
31 Jan 2019 Comp6 .0205 15368872 1.24155 26
31 Jan 2019 Comp7 .0928 27670030 .50101 27
31 Jan 2019 Comp8 -.0359 8280406 1.63821 28
31 Jan 2019 Comp9 .0786 14734958 .50472 29
I have 20 companies and 37 dates (Only showing 2). I`m trying to sort Marketcap and PBR by each date, for example, 31/12/2018, 31/01/2019, and so on. after sorting market cap, for example, I want to get the correspondent return for the sorted market cap and get the average of smalls, and the average of bigs and then the average of these 2. and I want to do the same thing to PBR.
could you help me figure out the right code for this.
I later have to use a bigger dataset, more than 2000 comps.
thank you
Comment