You don't seem to have a question that we can answer
for you. If you don't care which one you drop, then
it doesn't matter, and you can drop either. If
you do care, then you need to tell us a rule for
which to drop. (For drop read -drop-, throughout.)
Nick
[email protected]
sara borelli
> Hi Michael,
>
> I am sorry to write again about the question of
> yesterday
> I am not sure how I would change the code you
> suggested in the following case:
>
> claimnum personid servdate charge proc
> 4087 1000124 2001-06-06 +25274.25 121
> 4510 1000124 2001-06-06 -25274.25 121
> 4511 1000124 2001-06-06 +25274.25 121
>
> If I want to eliminate the negative charge AND both
> positive counterparts I just type drop if
> hasnegative==1.
>
> The problem is that I might need to drop the negative
> and only one of the positive counterparts, but the
> only variable that can distinguish between the two
> positives is claimnum, which cannot be used to define
> a group since it is unique to each observation
>
> thank you in advance
> Sara
>
> --- Michael Blasnik <[email protected]> ha
> scritto:
>
> > I'm not sure if you require that the charges exactly
> > offset each other or
> > not, but if they do, then this should work:
> >
> > gen abscharge=abs(charge)
> > bysort personid proc date abscharge (charge) : gen
> > hasnegative=charge[1]<0
> > bysort personid proc date abscharge : gen
> > sumcharge=total(charge)
> > drop if hasnegative & sumcharge==0
> > drop hasnegative sumcharge
> >
> > You may want to browse at the dataset prior to
> > issuing the drop command to
> > see if it does what you want.
> >
> > Michael Blasnik
> >
> > ----- Original Message -----
> > From: "sara borelli" <[email protected]>
> > To: <[email protected]>
> > Sent: Tuesday, March 06, 2007 1:48 PM
> > Subject: st: eliminate negative values and their
> > positive counterpart
> >
> >
> > > dear satalist members,
> > >
> > > This is an exctract of my data:
> > >
> > <snip>
> > > where the dots indicate that other values for the
> > same
> > > personid are in between. I need to eliminate the
> > > negative charges AND their positive counterpart
> > with
> > > the same proc and date. Thus, for example I need
> > to
> > > eliminate the negative
> > > -13 80048 6/7/2001
> > > AND its positive counterpart with the same proc
> > and
> > > date:
> > > +13 80048 6/7/2001,
> > > and so on.
> > > I should find a way to construct an algorithm that
> > > identifies and eliminates the negatives AND their
> > > poistive counterpart with he same date and
> > procedure,
> > > but I cannot figure that out.
*
* 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/