Statalist The Stata Listserver


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

Re: st: eliminate oppositie positive and negative values


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: eliminate oppositie positive and negative values
Date   Thu, 29 Mar 2007 08:32:41 -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[_n-1] & _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" <[email protected]>
To: <[email protected]>
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:

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 e-mail I
runned the following:
doesn't that mean that the charges for a given date should sum to zero?

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/



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