
From  "Michael Blasnik" <michael.blasnik@verizon.net> 
To  <statalist@hsphsun2.harvard.edu> 
Subject  Re: st: eliminate oppositie positive and negative values 
Date  Thu, 29 Mar 2007 08:42:32 0400 
That wouldn't work because there could be offsetting charges and non offsetting charges on the same date so the sum wouldn't be zero.
Although there may be better ways to do this, to repeat the loop until there is nothing to change you can use while loop that continues based on a test.
gen abscharge=abs(charge)
gen abs(xm)=abs(xm)
local go=1
while `go' {
bysort personid proc date abscharge abs(xm)(charge) :
gen byte todrop=charge!=charge[_n1] & _n>1
bysort personid proc date abscharge absxm (charge) :
replace todrop=1 if charge!=charge[_n+1] & _n<_N
qui count if todrop==1
if r(N)==0 local go=0
drop if todrop==1
drop todrop
}
Michael Blasnik
 Original Message  From: "Ronán Conroy" <rconroy@rcsi.ie>
To: <statalist@hsphsun2.harvard.edu>
Sent: Thursday, March 29, 2007 5:11 AM
Subject: Re: st: eliminate oppositie positive and negative values
*On 29 Márta 2007, at 02:41, sara borelli wrote:doesn't that mean that the charges for a given date should sum to zero?I need to drop the negatives and the positives with the same date abs(charge) abs(xm) proc personid. As suggested by Michael Blasnik in a previous email I runned the following:
If that's the case then can't you just sum the charges within each person within each date and check if they are zero?
* 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/
* * 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–2015 StataCorp LP  Terms of use  Privacy  Contact us  What's new  Site index 