Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Elapsed Time Paneldata


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Elapsed Time Paneldata
Date   Sun, 20 Jan 2013 11:45:05 +0000

Start with

bysort newid (date) : gen elapsed = date - date[1]

and then it is a matter of conversion of units (and some rounding) of
the result.

Nick

On Sun, Jan 20, 2013 at 4:38 AM, Steven Archambault
<archstevej@gmail.com> wrote:

> I have gone through the help docs, but cannot figure out how to keep a
> running tally of time elapsed in each panel from the beginning
> observation in each panel. In my data the date does not matter so
> much, but the time from the beginning of each panel does matter. In
> some cases, as in the example below, the panels are observed at
> different dates.
>
> I have
> newid   date
>       1     06feb2012 16:59:34
>       1     07feb2012 07:59:36
>       1     07feb2012 16:59:11
>       1     08feb2012 07:59:12
>       1     08feb2012 17:00:58
>       1     09feb2012 08:01:00
>       1     09feb2012 17:00:35
>        2    10feb2012 08:00:36
>        2    10feb2012 17:00:11
>        2    11feb2012 08:00:13
>        2     11feb2012 16:59:48
>
> I want to be able to generate
>
> newid days_elapsed
> 1              0
> 1             .5
> 1             1
> 1             1.5
> 1             2
> 1             2.5
> 1             3
> 2             0
> 2             .5
> 2             1
> 2             1.5
>
> Can anybody help me?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index