Hello guys,
My data set is like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Stock[/TD]
[TD]Return[/TD]
[TD]Criteria1[/TD]
[TD]Criteria2[/TD]
[TD]Percentrank.INC[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]0.1[/TD]
[TD]W[/TD]
[TD]0.9[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]0.3[/TD]
[TD]M[/TD]
[TD]0.7[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]0.2[/TD]
[TD]NA[/TD]
[TD]0.3[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]0.1[/TD]
[TD]L[/TD]
[TD]0.5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]0.5[/TD]
[TD]M[/TD]
[TD]0.33[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]0.2[/TD]
[TD]W[/TD]
[TD]0.88[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]0.1[/TD]
[TD]W[/TD]
[TD]NA[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]0.4[/TD]
[TD]L[/TD]
[TD]0.2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]0.2[/TD]
[TD]L[/TD]
[TD]0.77[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
What I want to do is to run double sorts in VBA. The sample here is cross-sectional, but my data also has time dimension. What I need to calculate is the percentrank.INC of each stock. Lets take stock 1 as an instance, this stock belongs to group W, and its value of criteria 2 is 0.9. I want to calculate the percentranl.Inc of its criteria 2 within the W group. (We also have NA in both criteria1,2 columns)
As what I mentioned, I also need to repeat this step over a long period. Therefore, I prefer to using VBA code for this scenario.
Thank you guys so much.
My data set is like this:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Stock[/TD]
[TD]Return[/TD]
[TD]Criteria1[/TD]
[TD]Criteria2[/TD]
[TD]Percentrank.INC[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]0.1[/TD]
[TD]W[/TD]
[TD]0.9[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]0.3[/TD]
[TD]M[/TD]
[TD]0.7[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]0.2[/TD]
[TD]NA[/TD]
[TD]0.3[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]0.1[/TD]
[TD]L[/TD]
[TD]0.5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]0.5[/TD]
[TD]M[/TD]
[TD]0.33[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]0.2[/TD]
[TD]W[/TD]
[TD]0.88[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]0.1[/TD]
[TD]W[/TD]
[TD]NA[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]0.4[/TD]
[TD]L[/TD]
[TD]0.2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]0.2[/TD]
[TD]L[/TD]
[TD]0.77[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
What I want to do is to run double sorts in VBA. The sample here is cross-sectional, but my data also has time dimension. What I need to calculate is the percentrank.INC of each stock. Lets take stock 1 as an instance, this stock belongs to group W, and its value of criteria 2 is 0.9. I want to calculate the percentranl.Inc of its criteria 2 within the W group. (We also have NA in both criteria1,2 columns)
As what I mentioned, I also need to repeat this step over a long period. Therefore, I prefer to using VBA code for this scenario.
Thank you guys so much.