I have a panel data. I want to assign a unique ID to each county within each state. For example, for all county within Maryland state, I want to generate a unique county ID (Baltimore: 1, Prince George: 2, and so on). Similarly, each county within New York State will have a separate ID (Queens: 1, Rockland: 2, and so on). I want to do this for each states in the US. Can I use the "foreach" command? Or is there a better way?
Thank you.