BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Annalena
Fluorite | Level 6

Hello everybody.

 

I have a data set which contains the following variables: date, firm and abnormal return. I attached a sample file.

I want to compute the cross correlation of the returns between the firms at each time stamp and then compute a mean cross correlation for the whole time period. I am a beginner in SAS and guess I need matrix notation but already got stuck on converting my data into a matrix.

 

Greatly appreciate your help!

1 ACCEPTED SOLUTION

Accepted Solutions
StatsMan
SAS Super FREQ

Cross-correlations are computed over multiple time periods (ie. lags) rather than over a single time point.  Also, one typically has a single dependent variable and multiple potential inputs, and a CCF analysis is performed to help you see how correlated other potential inputs are with that dependent variable.

 

I wonder if a similarity analysis might be more in line with what you need…

View solution in original post

5 REPLIES 5
Annalena
Fluorite | Level 6

Yes, I also found this procedure and have tried it but since there is very few explanations on syntax online I don't know how to implement it.

PeterClemmensen
Tourmaline | Level 20

I'm not entirely sure what your desired result looks like here? 

 

Perhaps like this?

 

proc sort data= ret.abnormalreturn out=abnormalreturn;
   by date;
run;

proc transpose data=abnormalreturn out=abnormalreturn_wide(drop=date);
    by date;
    id firm;
    var ar;
run;

ods select PearsonCorr;
proc corr data=abnormalreturn_wide noprob outp=OutCorr
          nomiss;
var _numeric_;
run;
Annalena
Fluorite | Level 6

Hi draycut,

 

i'm not sure if this does what i want since i need to calculate cross correlation and not only correlations.

I figured something out this morning and not sure if this is correct:

proc sort data=WORK.abnormalreturn out=WORK.SORTTempTableSorted;
	by Date Firm;
run;

proc transpose data=WORK.SORTTempTableSorted out=WORK.ARCor;
	var ar;
	id Firm;
	by Date;
run;

proc delete data=WORK.SORTTempTableSorted;
run;

proc timeseries data=ARcor outcrosscorr=crosscor;
	var _all_ ;
	id date interval=weekday; 
	crosscorr lag n ccf;
run;

proc means data=crosscor mean noprint;
	output out=cormean (drop=_type_ _freq_)
	mean(ccf)=roh ;
run;

Does this lead to the same output as the code you suggested? And if this is wrong and I should use your code, how would I compute a mean across all the correlations since their not in the same column?

 

Thanks for your support!

StatsMan
SAS Super FREQ

Cross-correlations are computed over multiple time periods (ie. lags) rather than over a single time point.  Also, one typically has a single dependent variable and multiple potential inputs, and a CCF analysis is performed to help you see how correlated other potential inputs are with that dependent variable.

 

I wonder if a similarity analysis might be more in line with what you need…

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 2695 views
  • 1 like
  • 4 in conversation