Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: date of last follow up


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: date of last follow up
Date   Tue, 13 Sep 2011 08:14:34 +0100

Richard says everything you need to know on this, but see also

FAQ     . . . . . . . . . . . . . . . . . . . . . . . Generating the last date
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        4/05    How can I generate a variable containing the last of
                several dates?
                http://www.stata.com/support/faqs/data/lastdate.html

bysort subjectid (visitdate) : gen maxvstdate = visitdate[_N]

would be equivalent for numeric dates, none of which were missing.

Nick

On Tue, Sep 13, 2011 at 7:54 AM, Richard Goldstein
<richgold@ix.netcom.com> wrote:

> if visitdate is a Stata date (see -h dates-), then just go
>
> egen maxvstdate = max(visitdate), by(subjectid)
>
> if visitdate is not a Stata date (e.g., it is a string), then make into
> a Stata date (-h dates-)
>
> Rich
>
> On 9/13/11 12:33 AM, Michael Eisenberg wrote:

>> I'd like some help working with dates in Stata.
>>
>> I have a list of visits for several patients.  I'd like to make a
>> column which lists the date they were last seen.  In other words, a
>> date of last follow up.
>>
>> I'm fairly certain I need to start with a bysort command, but I'm not
>> sure what should come next.
>>
>> My data looks as follows.
>>
>> subjectid   test      visitdate
>> 1                r            1-3-2010
>> 1                q            2-1-2009
>> 1                e            6-3-2011
>> 2                q            2-1-2006
>> 2                e            6-3-2008
>> 3               r              1-3-2005
>> 4                q            2-26-2009
>> 4                e            6-13-2011
>> 4                r             10-23-2010
>> 2                q            2-15-2007
>> 1                e            6-30-2004
>>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index