Dear all,
I am new to Statalist, and this is my first post. Thank you in advance for your support and guidance.
I am using Stata 16.
I have industry-level output for a set of home and destination countries covering 20 years and 15 industries.
I am estimating the effects of business cycle correlations between two countries of the export value. I would like to calculate and generate as a variable the correlation between the industry level output in the home country and the destination country. This is what my data looks like in brief: where h_go is industry level output in home country and go is industry output in destination country.

Array

I have tried the following code but it is not working:

Code:
sort home destination ind
 egen corr_ind = corr(h_go go), by(home destination ind)
I would appreciate any advice on this issue.
Thanks.