BookmarkSubscribeRSS Feed
crsp2021
Calcite | Level 5

I am trying to compute correlations between returns to many firms. A piece of data in SAS format is in the table below (permno is a firm identifier) - of course, I have more years and lots of firms (permno's) that enter and exit the sample.

What I am trying to do is to create a correlation matrix of firm returns for each year. The obvious solution is just to create a new return variable for each firm (return1 for return to permno=10001, return2 for permno=10002); then merge tiny files (year, month, returnX) by year month; then do proc corr with a by year clause. The downside is that the loop to do that runs for a long time and, like I said, firms enter and exit the sample.

Is there a short-cut? I tried proc mixed, but could not figure out how to make it deliver just a plain correlation matrix I described above, without filtering out any fixed/random effects.

 

permnoyearmonthreturn
1000120001-4.412
10001200021.538
1000120003-1.576
10001200041.172
1000120005-2.317
10001200062.767
1000120007-1.563
10001200084.762
10001200097.576
100012000102.857
100012000116.25
100012000123.268
1000220001-2.564
1000220002-16.316
10002200032.893
10002200041.235
1000220005-2.439
10002200064.125
1000220007-1.212
1000220008-1.84
1000220009-25.25
1000220001016.949
100022000111.812
100022000125.765

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 0 replies
  • 362 views
  • 0 likes
  • 1 in conversation