Hi all,

This might be a trivial question but whatever I have tried seems not working. (e.g. looping through the values of the variable fdi using forvalues and trying to generate new variables)

I have 2000+ territorial units (variable id) and the number of foreign firms located in each territory (variable fdi). My aim is to create a matrix similar to the one below. Namely, for each id, I want to create a new variable which is equal to the number of foreign firms in that territorial unit. Put differently, a matrix 2000 by 2000 is what I need

Will you please give me some hints regarding which commands I should look at/begin with?

Many thanks!

Array