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 on April 23, 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 calculation


From   Daniel Marcelino <dmsilv@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: date calculation
Date   Thu, 29 Sep 2011 18:05:40 -0400

I got the solution, despite in a non beautiful way:

bysort id: gen days = day[_n+1]
format days %td
gen days2 = days-day
bysort iddeputado: egen total = total(days2)
collapse total, by(id)

Daniel


On Thu, Sep 29, 2011 at 5:21 PM, Daniel Marcelino <dmsilv@gmail.com> wrote:
> Hello all,
>
> I'm fuzzing my mind to get into calculation of date vars. I've a data
> set with historic of events that I want to calculate number of days.
> However, I need to account for those occurrences in par of them, the
> first date is the enter and the subsequent date is the out. If the
> same id enter again it will receive new enter e new out date. My point
> is, how can I calculate the overall period regarding this intermediary
> calculation? Any thoughts is welcome.
>
>  day              flag_n       flag_N  id
> 07may2003       1       4          1
> 23feb2005               2       4          1
> 31mar2005       3       4          1
> 31jan2007       4       4          1
> 01feb2003               1       2          5
> 21dec2005       2       2         5
>
> Daniel
> *
> *   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/
>



-- 
About me: http://danielmarcelino.zip.net/

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