Statalist The Stata Listserver


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

RE: st: Re: eliminate negative values and their positive counterpart


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Re: eliminate negative values and their positive counterpart
Date   Wed, 7 Mar 2007 17:42:07 -0000

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 
n.j.cox@durham.ac.uk 

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 <michael.blasnik@verizon.net> 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" <saraborelli77@yahoo.it>
> > To: <statalist@hsphsun2.harvard.edu>
> > 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/



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