I am running a cross-sectional random effects regression. And I want to generate a new variable that consists of the correlation between two variables (say x and y) for each country. For each country this value will be a constant for all observations, because the correlation of x and y doesn't change and is unique for each country.
Using the following command Stata gave me a long list of, essentially, correlation of x and y for each country.
Code:
bysort country: corr y x
Appreciate if someone can help with this issue.
0 Response to Generate correlation as variable
Post a Comment