Statalist The Stata Listserver


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

st: eliminate oppositie positive and negative values


From   sara borelli <saraborelli77@yahoo.it>
To   statalist@hsphsun2.harvard.edu
Subject   st: eliminate oppositie positive and negative values
Date   Thu, 29 Mar 2007 03:41:26 +0200 (CEST)

Dear Statalist,
I have a question that is related to one I have posted
myself a couple of weeks ago:
I have 

num   personid  date       charge    proc    xm
406       124   2001-06   -5274      121     -1050
409       124   2001-06   -5274      121     -1050
409       124   2001-06   -5274      121     -1050
408       124   2001-06   +5274      121     +1050
451       124   2001-06   +5274      121     +1050
453       124   2001-06   +5274      121     +1768

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:

gen abscharge=abs(charge)
gen abs(xm)=abs(xm)
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
drop if todrop==1
drop todrop

this worked well, but now I would need also something
else.
After the second round it stops dropping negatives
since the remaining negative does not match anymore
the postive in  terms of xm. To run the algorithm
until it stops I have manually copied and pasted until
it stops dropping additional negatives. But in some
cases the number I have to do this gets large. Thus I
would like to know if there is a way to say stata to
run the algorithm up to the point where no additional
negative values are dropped

thank you very much for any suggestion you might have
Sara



	

	
		
___________________________________ 
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index