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   "Deborah Garvey" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Bysort on non-selection variables
Date   Wed, 20 Jul 2005 13:30:43 -0700

Thank you kindly, Richard, for taking the time and effort to propose a solution.  Unfortunately, -sort-ing as you suggest does not preserve the "serial pernum" ordering I require for the conditions on the -bysort-.

I'll have to try another tack.

Thanks again,

Deb

--------------------------------------------------------------------------------
From: Richard Williams <[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.
>
>Thanks,
>
>Deb
>
>. 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):    http://www.nd.edu/~rwilliam 
WWW (department):    http://www.nd.edu/~soc 


******************************
Deborah Garvey, Ph.D.
Department of Economics
Kenna Hall
Santa Clara University
Santa Clara, CA  95053
408/554-5580
408/554-2331 (FAX)
[email protected]    
http://lsb.scu.edu/~dgarvey
**********************************


This message scanned for viruses and SPAM at SCU (MGW2)

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index