Hi Stata people,

I have two questions, I want to apply merger simulation after running a two-level nested logit model demand. For the first step, I want to define my panel data, and since I have different markets at different times, my panel data has three dimensions. my Vendors, different times, and different markets. I could define it but for the xtset command, I have repetition in my time variable. I use the following codes:

egen qm = group (quarter market_name), label
xtset Vendor qm
drop if qm==qm[_n-1]


but Stata is not removing all the repetitions. first, some of them and then when I do my xtset comes again the failure there are some repetitions and then I need to run the drop codes for the second time and then all the repetitions will be removed. why is it like this? why Stata doesn't remove all of them the first time of running?

The second question is:
I sort my vendors and for the command " mergersim simulate if quarter == 188 &market_name=="NEW YORK", seller(50) buyer(52) detail" every time when I run the codes the id of the seller and buyer ( the Vendors which I want to do the merge between them) is getting different. once they are 50 and 52, next time is 150 and 300. and next time something different. Why is it like this? how can I fix it?

I appreciate any answer!!!