Hi Michael,
thank you so much again for your help, I really
appreciate it!
Sara
> Woops, I copied your own syntax errors below.
> Clearly, yoiu can't have a
> variable named abs(xm) and the code should be
> changed to absxm. Also, I would
> combine replace todrop line in with the gen todrop
> line as one logical
> condition, since it should be faster that way,
> especially if you are working
> with a large dataset and many times though the loop.
>
> Michael
>
> ----- Original Message -----
> From: "Michael Blasnik"
> <[email protected]>
> To: <[email protected]>
> Sent: Thursday, March 29, 2007 8:32 AM
> Subject: Re: st: eliminate oppositie positive and
> negative values
>
>
> > 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/
>
> *
> * 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/