Statalist The Stata Listserver


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

Re: st: bysort problem


From   "Nikolaos A. Patsopoulos" <npatsop@cc.uoi.gr>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: bysort problem
Date   Mon, 26 Feb 2007 13:48:36 +0200

Quoting Svend Juul <SJ@SOCI.AU.DK>:

> Nikos wrote:
>
> I'm currently writing a program that in some point checks
> if more than observations have two vars (E and SE) equal.
> If more than one exists then SE is increased by 0.001:
>
> tempvar _id
> qui gen `_id'=0
> local _idN=2
> while `_idN'!=1 {
> bysort `E' `SE': replace `_id'=_n if `touse'
> count if `_id'>1 & `touse'
> replace `SE'=`SE'+(`_id'-1)*0.001 if `_id'>1
> sum `_id' if `touse', detail
> local _idN=r(max)
> list `E' `SE' `_id' if `touse'
> }
>
> when I run the above piece of code bysort fails in the second pass:
>
> 2
> (2 real changes made)
> ----------------------------------------------------
>
> I have no intent to try to understand the above commands. But
> to help yourself you might use the -trace- command. To restrict
> the amount of output you might also use -set tracedepth- :
>
>    set tracedepth 1
>    set trace on
>    - and run the program
>
> This will let you se how your macros expand.
>
> Hope this helps
> Svend
>
> __________________________________________
>
> Svend Juul
> Institut for Folkesundhed, Afdeling for Epidemiologi
> (Institute of Public Health, Department of Epidemiology)
> Vennelyst Boulevard 6
> DK-8000  Aarhus C, Denmark
> Phone: +45 8942 6090
> Home:  +45 8693 7796
> Email: sj@soci.au.dk
> __________________________________________
>
> *
> *   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/
>

I did trace the code but the only thing showing is that bysort is not working
properly on the second pass.
*
*   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