I ran a cross-correlation analysis using PROC TIMESERIES, and found a correlation of 0.51695 at a lag of 1. I wanted to then find the associated significance level, so I created a new data set with the appropriate lag and applied PROC CORR, which gave me 0.52006. I also tested the correlation w/o any lag and both gave me exactly 0.1460650864, so I presume it's an error somewhere with the lagging. I looked at the outputted datasets however, and it all seems to be in order. The difference is pretty minor, but should I be concerned?
proc timeseries data=final2 crossplots=ccf outcrosscorr=final3;
id weeks interval=day accumulate=none;
var ncresiduals gtresiduals;
run;
data final4;
set final2;
gt3=lag(gtresiduals);
run;
proc corr pearson data=final4 out=final5;
var gt3;
with ncresiduals;
run;
The formulas on the documentation page you provided explain why you are not getting the same values when there is a lag. Note that in the cross covariance formula it is always the mean of y that is being used regardless of the lag value. In your example code the variables gtresiduals (y) and gt3 (the lagged values you created) will (very likely) have different means. As @PaigeMiller said the two procedures are computing different quantities.
PROC TIMESERIES (as far as I know), does not compute correlations, it computes auto-correlations, and so this should not be the same as PROC CORR which does computer correlations.
Cross correlations from PROC TIMESERIES are not the same as CORRELATIONS from PROC CORR. I don't think they should match.
The formulas on the documentation page you provided explain why you are not getting the same values when there is a lag. Note that in the cross covariance formula it is always the mean of y that is being used regardless of the lag value. In your example code the variables gtresiduals (y) and gt3 (the lagged values you created) will (very likely) have different means. As @PaigeMiller said the two procedures are computing different quantities.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.