Deets McGeets
Deets McGeets

Reputation: 6377

In SAS, how do I find correlations along a single column of data by another variable?

Let's say I have daily stock returns for 100 stocks in 1990. I want to calculate the correlation matrix of the returns of all these stocks. But instead of having 100 columns of returns data with 1 column for each stock, I have 1 column of returns data with a second column of ticker symbols and a 3rd column of dates.

(Note that these stocks might change from year to year, but I want to calculate the correlations of returns in each year.)

Many thanks for your help.

Upvotes: 1

Views: 263

Answers (1)

DWal
DWal

Reputation: 2762

I'd just transpose the data to get one row for each day and one column for each stock:

proc transpose data=have out=want;
  by date;
  id symbol;
run;

Then proceed from there.

Upvotes: 2

Related Questions