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: date calculation


From   Daniel Marcelino <[email protected]>
To   [email protected]
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 <[email protected]> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index