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: RE: roundup %tc variable to nearest 10sec


From   Joe Canner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: roundup %tc variable to nearest 10sec
Date   Sat, 26 Oct 2013 23:12:06 +0000

Shu,

For the rounding part, since a %tc value is in milliseconds, you should be able to use -round(conv_time,10000)- to round to the nearest 10 seconds.

Regards,
Joe Canner
Johns Hopkins University School of Medicine
________________________________________
From: [email protected] [[email protected]] on behalf of Ng, Shu Wen [[email protected]]
Sent: Saturday, October 26, 2013 6:54 PM
To: [email protected]
Subject: st: roundup %tc variable to nearest 10sec

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/

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