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/