Hi guys, I am currently working on a dataset in long format and I need the average corss-correlation of all variables. I have tried to convert the dataset from long to wide using the reshape code but Stata returns 'values of variable t not unique within firmid'. I also tried it with a loop with the command xcorr, but I cannot find the correct way to do it. Can someone please help me?
The dataset looks like this:

firmid t return
1 -20 0,02
1 -19 -0,1
1 -18 0,014
1 -17 etc.
2 -20
2 -19
2 -18
2 -17
etc...

So I need the average cross-correlation at time -20, the average cross-correlation at time -19 etc stored as a new variable.

Huub