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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.