Hi Everyone, I am struggling with a task in SAS. I am trying to consolidate a Matrix into distinct rows and columns using the weighted average of a variable to perform the consolidation. The data that I am working with is shown below. I need to collapse/consolidate the matrix so that each "Consolidated_Rating" row is distinct. I need to use the "nb" variable to create a weighted average to perform the consolidation. For example, to create a distinct row for "AA", I will find the weighted average of the following rows ("AA1","AA2", & "AA3"). The weighted average should be created using the "nb" variable for the above letter ratings. As I see it, there are two key parts to the task: 1. Perform this consolidation across rows (by using the weighted average where the "nb" variable is used as the weighting function) and across columns (This part is much simpler, I simply take the simple Average of the columns to perform the consolidation). 2. The additional complication I face is for the corner rating grade for each column. this requires a more complex calculation. I have managed to create exactly what I want in Excel as a starting point. The attached excel workbook contains the exact calculation that I need to perform. If there is additional information that I can add, please let me know. All help is greatly appreciated. DATA INPUT;
input Nb$ Rating$ CONSOLIDATED_RATING$ AAA AA1 AA2 AA3 A1 A2 A3 BBB1 BBB2 BBB3 BB1 BB2 BB3 B1 B2 B3 C1 C2 C3 CC D;
datalines;
2768 AAA AAA 87.4277 5.5275 2.9263 0.8309 0.1806 0.2529 0.1445 0 0 0 0 0.0723 0 0 0.0361 0 0 0.0723 0 0 0
1394 AA1 AA 2.5825 77.5466 11.1191 4.0172 0.7891 0.3587 0.2152 0.0717 0.1435 0.0717 0 0 0 0 0 0 0 0 0 0 0
4482 AA2 AA 0.4462 1.1825 81.3253 8.0321 2.5881 1.1379 0.4462 0.4016 0.1785 0.0669 0.0669 0.0446 0.0223 0.0223 0 0.0223 0 0.0446 0 0.0223 0.0223
4523 AA3 AA 0.0663 0.1548 3.8691 77.8023 10.3913 2.1888 0.6633 0.2874 0.199 0.1105 0.0442 0 0 0.0442 0.1327 0 0 0 0 0 0.0221
6498 A1 A 0 0.0462 0.5386 4.3706 78.3318 8.7412 2.5546 0.7695 0.3078 0.0769 0.0769 0.0923 0.0154 0.0923 0.0462 0 0 0 0 0 0.0462
9431 A2 A 0.053 0.053 0.2969 0.4559 4.9305 78.6555 6.9876 2.7038 1.0815 0.2863 0.159 0.159 0.0848 0.1166 0.0212 0 0 0.0106 0 0.0106 0.0636
8710 A3 A 0.023 0.0115 0.0689 0.1263 0.4707 6.1653 77.9334 7.853 2.2732 0.5052 0.1263 0.1378 0.1263 0.1493 0.023 0.0115 0 0.0115 0 0.023 0.0574
8550 BBB1 BBB 0 0.0117 0.0468 0.0234 0.2339 0.8655 7.3099 74.9825 8.7251 1.7895 0.386 0.3275 0.1637 0.2105 0.117 0.0234 0 0.0234 0 0.0117 0.1053
9924 BBB2 BBB 0.0101 0 0.0302 0.0101 0.1008 0.3829 1.1084 7.497 75.8061 6.6707 1.4208 0.6751 0.3023 0.262 0.1411 0.0403 0.0202 0.0202 0.0101 0.0202 0.1411
7359 BBB3 BBB 0.0136 0 0.0272 0.0544 0.0544 0.1495 0.3261 1.3453 9.3899 72.4283 5.7481 2.3101 1.0192 0.3805 0.299 0.1767 0.1767 0.0544 0.0136 0.0679 0.2446
4433 BB1 BB 0.0677 0 0 0 0 0.1128 0.0902 0.5414 2.0528 11.9558 64.2229 7.5795 3.316 1.1956 0.6993 0.2256 0.1353 0.1353 0.0902 0.0226 0.2707
5718 BB2 BB 0 0 0.0525 0 0 0.07 0.07 0.1924 0.5946 2.4484 9.7936 64.638 8.8492 2.6058 1.1542 0.4022 0.1749 0.1574 0.1049 0.07 0.6296
7363 BB3 BB 0 0 0 0.0136 0.0136 0.0136 0.0679 0.1358 0.2445 0.3939 1.8742 9.8329 62.8548 9.2489 3.3818 0.8692 0.2852 0.2716 0.0951 0.1087 1.1408
10333 B1 B 0 0.0097 0 0.0387 0 0.0387 0.0774 0.0581 0.0484 0.0968 0.2903 1.5484 7.8874 63.9892 9.2906 2.6323 0.9775 0.5323 0.1548 0.1645 2.2549
8562 B2 B 0 0 0.0117 0.0117 0 0.0467 0.0584 0.0117 0.0701 0.0234 0.1518 0.2569 1.3198 8.0589 62.1934 8.8881 2.4177 1.168 0.3621 0.327 4.1345
3831 B3 B 0 0 0 0 0.0261 0.0261 0 0.1044 0.0522 0.1566 0.1044 0.1827 0.5482 2.6364 10.1018 52.6494 7.7264 3.289 1.1224 0.8353 8.5095
1252 C1 C 0 0 0 0 0.0799 0 0 0 0.0799 0.1597 0 0.0799 0.4792 1.5176 3.6741 11.5016 34.984 6.4696 3.115 1.0383 23.3227
779 C2 C 0 0 0 0 0 0 0.1284 0.2567 0.1284 0 0 0.3851 0.1284 0.7702 2.8241 6.8036 5.6483 36.5854 2.3107 1.7972 27.9846
261 C3 C 0 0 0 0 0 0 0 0 0 0 0 0 1.1494 0.7663 1.1494 3.0651 4.2146 5.7471 27.9693 3.0651 39.8467
171 CC CC 0 0 0 0 0 0 1.1696 0 0 0 0 0.5848 0.5848 0.5848 1.7544 2.3392 1.7544 8.7719 0 11.6959 61.9883
0 D D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
;
run; All help is very much appreciated
... View more