Hi statalist,
Please, could anyone help me?

My data contains id, city, month , year and x1. The variable x1 varies per month, year and city. I want to randomly re-assign the cities across the ids. So, for example, id 1 is located on city 10. I want to randomly change that, so id 1 would be located in city 11.
After that, I would run my regression using this new randomly 'fake' data generated. And would repeat it 1000 times. My goal is to look at 1000 _betas and 1000 p-values from these simulations.

So, what I wish to do is:
  1. randomly change the cities linked to each id,
  2. do a regression
  3. Save betas, standard errors and p-values in a file
  4. Repeat this 1000 times

Thank you very much.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id city month year x1)
 1 10  2 2000 1000
 2 11  2 2001 5000
 3 10  3 2002  300
 4  2  4 2001  200
 5 14  1 2004 1000
 6  9 10 2006 2050
 7 15 11 2008 3999
 8 14  2 2009  900
10  9 11 2010  802
11 11 12 2001  456
12 19  9 2000  788
13 10  7 2011  100
14 10 10 2012 2000
15  2  2 2013   78
16 12  3 2003 1000
17 11  5 2004 1782
18 12 12 2009 4521
19 19  8 2008 1982
20 14  8 2006  335
end