Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: bysort problem

From   "Austin Nichols" <>
Subject   Re: st: Re: bysort problem
Date   Mon, 26 Feb 2007 11:51:10 -0500

Nikolaos A. Patsopoulos--
No loop should be necessary, as this example demonstrates.  My guess
is that this exercise is also not necessary, but as your ultimate
desired outcome is not explicit, I cannot know if replacing values is
actually a good idea for you.

input var1 var2
.145 .14
.145 .15
.145 .15
.167 .15
1.89 .15
1.89 .16
1.89 .16
egen oldgroup=group(var1 var2)
bys var1 var2: gen obs=_n
replace var2=var2+c(epsfloat)*obs
egen newgroup=group(var1 var2)
li, noo clean

On 2/26/07, Nikolaos A. Patsopoulos <> wrote:
The purpose of the code is to eliminate duplicate observations of var1 &
var2 (combination).
In the firest pass the algorithm fixes duplicates but new ones might
come-up, so it should run as long as noone is left. The correction is
too small for the real data (the ones here are dummy ones just to test
the code) and the possibility of duplicates very small but still present.

var2 is changed not var1. This was a mistake I made on earlier e-mail.
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index