Hello Statalists,
I've only coded for single-sorted quartile portfolios in Stata but now I need to construct a double-sorted quartile portfolio. Put it simply is, in each quarter, I wanna firstly sort all stocks into quartiles based on their institutional ownership (tmi1). Next, with each quartile in each quarter, I wanna sort them into another set of quartiles based on their monitoring attention (wtio). Does anyone possibly know how to code in this way? I will be really grateful if any help comments are given. Many thanks in advance!
Here is a partial dataset:
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 33 out of 513687 observations
I've only coded for single-sorted quartile portfolios in Stata but now I need to construct a double-sorted quartile portfolio. Put it simply is, in each quarter, I wanna firstly sort all stocks into quartiles based on their institutional ownership (tmi1). Next, with each quartile in each quarter, I wanna sort them into another set of quartiles based on their monitoring attention (wtio). Does anyone possibly know how to code in this way? I will be really grateful if any help comments are given. Many thanks in advance!
Here is a partial dataset:
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float quarter double(tmi1 wtio) 117 0 .00014276566598830893 118 0 .0001755080414020555 119 0 .0001991004412036009 120 0 .00024617221132283473 121 0 .0002354729108330631 122 0 .0002651689932122743 123 0 .0002275756588937073 124 0 .00008437844694620305 125 0 .00003834384297903891 126 0 1.422305485063643e-09 127 0 7.673856332974414e-09 128 0 4.842226747841946e-08 129 0 6.098118635452773e-08 130 0 1.0750975821075236e-07 131 0 1.412647771956958e-07 132 0 1.9660068313479758e-07 133 0 2.643924890089161e-07 134 0 4.2989573086812293e-07 135 0 6.760521129931567e-07 136 0 7.645901953251392e-07 137 0 6.903121146701238e-06 138 0 7.332357899342033e-06 139 0 7.66037555616215e-06 140 0 1.0702806958231637e-06 141 0 3.356142584589346e-08 142 0 2.8489726219135167e-08 143 0 2.919635418372186e-08 144 0 4.2363554399705993e-07 145 0 3.9909727128928835e-07 146 0 1.0368295044984471e-07 147 0 1.2051755094269015e-07 148 0 4.1842950920091276e-07 149 0 5.57991055698808e-07 end format %tq quarter
Listed 33 out of 513687 observations

Comment