Let's say I have the following data on firm size, profitability, and stock returns. The firms are sorted into terciles according to size and profitability like so:
Obs | Size_Tercile | Profitability_Tercile | Stock_Return |
---|---|---|---|
1 | 1 | 1 | .12 |
2 | 1 | 1 | .03 |
3 | 1 | 2 | .21 |
4 | 1 | 2 | .37 |
5 | 1 | 3 | .14 |
6 | 1 | 3 | .07 |
7 | 2 | 1 | .19 |
8 | 2 | 2 | .17 |
9 | 2 | 2 | .06 |
10 | 2 | 2 | .11 |
11 | 2 | 3 | .42 |
12 | 2 | 3 | -.13 |
13 | 3 | 1 | .03 |
14 | 3 | 1 | .05 |
15 | 3 | 2 | .22 |
16 | 3 | 3 | -.16 |
... | ... | ... | ... |
What's the most efficient way to program a double sort? I want to get average returns for the intersection of each size tercile with each profitability tercile:
Average Stock Returns sorted by firm size and profitability | |||
---|---|---|---|
Profitability Terciles <-> | |||
Size Terciles \/ \/ | 1 | 2 | 3 |
1 | ... | ... | ... |
2 | ... | ... | ... |
3 | ... | ... | ... |
I'm looking for efficiency here because this process will be repeated for several different variables sorted not necessarily by just terciles. Thanks in advance.
I'm not sure if I got the picture clear, but PROC SUMMARY using CLASS is usually very efficient.
/Linus
Hi Jaxonmills,
Have you solve this problem? Please share with me, I am working on it now but I havenot found the solution for it.
Thank you very much.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.