Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Bysort on non-selection variables

From   Richard Williams <[email protected]>
To   [email protected]
Subject   RE: st: RE: Bysort on non-selection variables
Date   Tue, 19 Jul 2005 19:25:47 -0500

At 03:46 PM 7/19/2005 -0700, Deborah Garvey wrote:
Dear Nick,

Thanks for suggesting the -stable- option. It crossed my mind after reading the -sort- thread from last month. However, the -stable- option with -sort- doesn't keep the data in serial/pernum order at the -bysort- command. Did I mess something up? Test commands and sample output below.



. use "C:\dlgarvey\Census data\IPUMS data\temp.dta", clear
. sort serial pernum, stable
. gen test=momloc
. bysort serial (test): replace test=8 if momloc==1
(30 real changes made)
. l serial pernum momloc test
The -bysort- command is changing the sort order. The sort command sorts by serial & pernum, bysort sorts by serial and test. Perhaps you want to add test to the sort command, e.g. -sort serial test pernum, stable-

Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal):
WWW (department):

* For searches and help try:

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