Sergiy Radyakin--
Yes, there is a guarantee of the type you desire. By construction,
obs ranges from 1 to the number of observations to be made distinct.
Thus a different number will be added to each obs. Your solution of
adding noise is not guaranteed to work, but would fail with a small
probability.
The numbers added are intended to be small enough to have a negligible
effect on the mean of var2 in almost all cases, though the technique
could be improved on for the somewhat implausible limiting cases:
bys var1 var2: gen obs=_n-(_N+1)/2
replace var2=var2+c(epsfloat)*obs
On 2/26/07, Sergiy Radyakin <Radyakin@aoek.uni-hannover.de> wrote:

Is there a guarantee, that var2+c(epsfloat)*obs will be a unique value (will
not overlap with the next value)? It is true in the example, but it is not a
general case.
consider var1=0.5 and var2 equal to
c(epsfloat)
c(epsfloat)
c(epsfloat)
c(epsfloat)
This seems to be also a solution:
replace var2=var2+uniform()/100000
simply add a small random number (noise) to var2. Chances that there will be
coincidences are also small, but they may not be ignored.

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/