Gsort Stata. You cannot use this option with gsort b. If there are 2 variables var1 and var2 after sort stata will sort the observations according to var1 first.
Then for observations with common var1 stata will sort them according to var2. To remedy this problem gsort s generate option will create a new grouping variable that is in ascending order thus satisfying stata s narrow definition and that is in terms of the groups it defines identical to that of the true sort variables. Assume you have sorted your data by country and within country by region.
You cannot use this option with gsort b.
The preferred method is to specify a combination of variables that uniquely identifies your observations. If there are 2 variables var1 and var2 after sort stata will sort the observations according to var1 first. Use the option stable to make sure stata uses the same randomization every time i. To remedy this problem gsort s generate option will create a new grouping variable that is in ascending order thus satisfying stata s narrow definition and that is in terms of the groups it defines identical to that of the true sort variables.