[P] set sortseed -- Set the default seed for randomly breaking ties in
set sortseed #
set sortseed specifies the seed used for the random-number generator that
breaks any ties in the key values when data are sorted. This affects the
commands sort and gsort, as well as any commands that use sorting as part
of their computation.
set sortseed should be used rarely. Access to the sorting seed is
provided solely for those doing replication studies, where occasionally
it is necessary to set the sort seed to produce numerically identical
results for computations whose results may change slightly when the
computations are run repeatedly. These changes are typically in the
digits beyond those displayed by the command, but these might be compared
nevertheless in a replication study.
The current value of sortseed can be obtained by accessing stored result
r(sortseed) after issuing the command query sortseed.
Using set sortseed outside of such comparisons is strongly discouraged.
Many data manipulations depend on sorts being specified fully and
correctly, and setting the sorting seed can disguise logic problems in
data management. For a discussion, see a posting on Statalist about this
Obtain the sorting seed, perform some operations which change the sort
order of the data (and thus change the sorting seed), and then reset the
. query sortseed
. local origseed = r(sortseed)
...any command(s) which change the sort order of the data...
. set sortseed `origseed'