Statalist


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

Re: st: AW: Divide the time in equal intervals


From   Beatrice Crozza <[email protected]>
To   [email protected]
Subject   Re: st: AW: Divide the time in equal intervals
Date   Thu, 12 Nov 2009 17:04:09 +0000

Dear Martin,

thank you very much for your reply, but maybe I didn't explained very
well my problem.
This is my database:

  Date              Time             Quantity
12/04/2009         9:07:21           5
12/04/2009        10:10:21         10
12/04/2009        10:13:23         16
                           ...               ....
 13/04/2009        10:12:54        3
                         ....               ....
 14/04/2009        13:20:56        13

Now I want to divide my time in 5-min interval from 8:30:00 to
17:30:00 for each day, so on 12/04/2009 I would like to have:

  Date              NewTime       Quantity
12/04/2009       8:30:00             0
12/04/2009       8:35:00             0
12/04/2009       8:40:00             0
                       ....
12/04/2009        9:10:00           5
12/04/2009       10:15:00         26  (10+16)
                           ...               ....
How could I do?

Tank you very much

Bea

2009/11/12 Martin Weiss <[email protected]>:
>
> <>
>
>
>
> *************
> clear*
>
> inp str10(Date Time) Quantity
> "12/04/2009" " 9:07:21 "  5
> "12/04/2009" "10:10:21 " 10
> "12/04/2009" "10:13:23 " 16
> "13/04/2009" " 10:12:54" 3
> "14/04/2009" "13:20:56 " 13
> end
>
> replace Date=trim(Date)
> replace Time=trim(Time)
>
> bys Date: keep if _n==1
>
> gen str20 start=Date+" "+ "8:30"
> gen double start2= /*
> */ clock(start, "DMYhm")
>
> expand 103
>
> bys Date: gen double myvar= /*
> */ start2+(_n-1)*msofminutes(5)
> format myvar %tcMon_dd,_CCYY_HH:MM
> drop  start start2 Time
> list, noobs h(30) sepby(Date)
> *************
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Beatrice Crozza
> Gesendet: Donnerstag, 12. November 2009 17:16
> An: [email protected]
> Betreff: st: Divide the time in equal intervals
>
> Dear all,
>
> I have my database with 3 variables:
>
>     Date              Time             Quantity
> 12/04/2009         9:07:21           5
> 12/04/2009        10:10:21         10
> 12/04/2009        10:13:23         16
>                           ...               ....
> 13/04/2009         10:12:54       3
>                         ....               ....
> 14/04/2009        13:20:56        13
>
> I would like to divide the time in equal intervals of 5-min from
> 8:30:00 to 17:00:00 for each day.
>
> If I use the function:  egen newtime cut(time), at(...)
>
> I have the result but of course in my newtime I will have only the
> time that I already have in time, but equally intervalled.
> Instead, I would like to have newtime for every 5-min intervals, this
> means that I would like to have also 8:30:00 in my newtime with a
> quantity of zero.
>
> How can I reach this result?
>
> Thank you very much.
>
> Best,
> Bea
> *
> *   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/
>
>
> *
> *   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/
>

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index