Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Joe Canner <jcanner1@jhmi.edu> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | st: RE: Question: date format |
Date | Thu, 12 Sep 2013 13:19:26 +0000 |
Thomas, I don't see anything in the documentation about displaying a Stata datetime variable as just a time. Generally speaking, times without dates are kind of useless, which is probably why they didn't provide for this. I would suggest you combine the date variable and the time variable into one datetime variable. Say your original date variable is -date1- and your time variable is -time1-: . gen datetime1=cofd(date1)+time1 -cofd()- converts your date to a datetime with midnight as the time. Your time variable is the number of milliseconds past midnight. So, the sum should be a legitimate datetime variable. Later, if you need information on just the time you can extract it using the hh(), mm(), and ss() functions. Regards, Joe Canner Johns Hopkins University School of Medicine -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Thomas Bourveau Sent: Thursday, September 12, 2013 8:40 AM To: statalist@hsphsun2.harvard.edu Subject: st: Question: date format Dear Statalist members, I obtained data on the timing of some announcements made by firms. For each event, I have two different variables: one variable for the date, and another one for the hours, minutes and seconds of the timing. However, when I obtained the second variable, it looks like this: 01jan1960 13:57:54 01jan1960 23:17:48 01jan1960 08:32:52 Specifically, for each line, "01jan1960" is written before each hours, which was not supposed to be. The variable is in a long format (%tcHH:MM:SS) and I don't know how to drop the "01jan1960" for each line. If anyone has a suggestion, that would be nice. Thanks a in advance Best, Thomas -- Thomas Bourveau thomas.bourveau@gmail.com 0637573925 * * 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/