Statalist The Stata Listserver

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

Re: st: bysort problem

From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <>
Subject   Re: st: bysort problem
Date   Mon, 26 Feb 2007 12:46:09 +0100

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 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 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

*   For searches and help try:

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