Statalist The Stata Listserver


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

Re: st: replace values of all members of a group with the values of one


From   "Sebastian F. B�chte" <[email protected]>
To   [email protected]
Subject   Re: st: replace values of all members of a group with the values of one
Date   Tue, 23 May 2006 09:22:59 +0200

Tessa,

. gen test = date if  def_inrange == 1
. bysort  donor_id  def_inrange date (test): replace test = test[1]

Can anyone tell me why this is not working?
If this is not appropriate, are there any quick and easy alternatives?
I think the problem is the way you form the by-group over donor_id,
def_inrange, and date, thus opening a new group for each value of
def_inrange. In order to achieve what you want you could go this way:

/* generating a variable holding the date from the appointment with
 def_inrange==1, this will only work if there are no missing values in
 def_inrange!
*/
bysort donor_id (def_inrange): gen test=date[_N]

Sebastian

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