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   sara borelli <[email protected]>
To   [email protected]
Subject   Re: st: Re: eliminate negative values and their positive counterpart
Date   Wed, 7 Mar 2007 18:37:23 +0100 (CET)

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.
> > Any help would be really appreciated
> >
> > thanks
> > Sara Borelli
> 
> *
> *   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/
> 



	

	
		
___________________________________ 
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: 
http://it.docs.yahoo.com/nowyoucan.html
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index