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 15:04:52 +0200

Jeph Herrin wrote:

What is -var3-?

Nikolaos A. Patsopoulos wrote:


All observations are as they appear. No extra decimals. Here is a revision without touse and locals

tempvar _id
qui gen `_id'=0
local _idN=2
while `_idN'!=1 {
bysort var1 var2: replace `_id'=_n'
count if var3>1
replace var1=var1+(`_id'-1)*0.001 if `_id'>1
sum `_id', detail
local _idN=r(max)
list var1 var2 '_id'
}

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

var3 is sth like an Id var. In a normal database the values will be unique sting identifiers, e.g. "Nikos 1998" 'Tom 2006" etc.

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