I am working on paneldata (xtset firm date). Before starting my regression analyses, I want to construct a Pearson Correlation Matrix between the variables. I did the following:

-estpost corr logott logqmcap io1 exitstock litigationstock mcap usd_volume sharevol turn prc rspr ilr bm idiovol r212, matrix listwise

-est store c1

-esttab * using test_correlation.rtf, unstack not noobs compress replace star(* 0.10 ** 0.05 * 0.01) label title(Correlation Matrix)

However, this method is not the right way to do it since it concerns Panel data. My question is how I can make it work? My guess would be to first construct the correlations by firm, and then average those correlations across firms. But I have no clue how to do this.

Hope you guys can help me out