Dear Statalist,
I have again 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 -972 121 -600
409 124 2001-06 -972 121 -200
409 124 2001-06 972 121 100
408 124 2001-06 972 121 250
451 124 2001-06 972 121 850
I need to drop the negatives and the positives with
the same date abs(charge) proc personid AND with the
CLOSEST NUMERIC MATCH IN TERMS of xm, that is I want
to drop the first negative (-600) together with 850
and the second negative (-200) together with 250.
I a different situation I used the following
alogorithm suggested by Michael Blasnik in a previous
e-mail:
gen abscharge=abs(charge)
bysort personid proc date abscharge (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
but I am not sure how to modify this or create
something new to account for my new situation .
Thanks 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/