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]

st: roundup %tc variable to nearest 10sec


From   "Ng, Shu Wen" <shuwen@unc.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: roundup %tc variable to nearest 10sec
Date   Sat, 26 Oct 2013 22:54:21 +0000

I need help in rounding up the %tc variable conv_time below to the nearest 10th second and then add new rows for when a 10 second interval is missing. 

For example, I currently have:
conv_date       conv_time (%tc)
8/22/2013        10:13:44 PM
8/22/2013        10:13:54 PM
8/22/2013        10:14:04 PM
8/22/2013        10:14:15 PM
8/22/2013        10:14:25 PM
8/22/2013        10:14:35 PM
8/22/2013        10:14:45 PM
8/22/2013        10:14:55 PM
8/22/2013        10:15:06 PM

I want to get:
conv_date       conv_time (%tc)    new_time (%tc)
8/22/2013        10:13:44 PM         10:13:40 PM
8/22/2013        10:13:54 PM         10:13:50 PM
8/22/2013        10:14:04 PM         10:14:00 PM
                                                      10:14:10 PM
8/22/2013        10:14:15 PM         10:14:20 PM
8/22/2013        10:14:25 PM         10:14:30 PM
8/22/2013        10:14:35 PM         10:14:40 PM
8/22/2013        10:14:45 PM         10:14:50 PM
8/22/2013        10:14:55 PM         10:15:00 PM
8/22/2013        10:15:06 PM         10:15:10 PM

Any advice on how to do this? I am new to datetime functions and have tried a few things, but nothing appears to have worked.
Thanks!
~Shu

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