Statalist


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

st: Support for negative time-format (duration)


From   Steinar Fossedal <steinar.fossedal@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Support for negative time-format (duration)
Date   Wed, 30 Sep 2009 19:03:09 +0200

Hi, listers

I'm currently working on a dataset where I am interested in examining
the observations' time difference compared to a base time. Thus I have
defined the variable

gen double timediff = observedtime - basetime
format timediff %tcHH:MM:SS

In cases with negative timediff, this format displays the results as
e.g. 23:50:00 (for 10 minutes negative). I would like the results
displayed as -00:10:00, so they can be easily related to the positive
timediffs. Besides improved readability in the dataset, this would
enable me to create a histogram on timediff, showing the spread in
timediff on both the positive and negative side.

I need to work on the timediff as the basetime is different for
different groups in the dataset, so I can't simply make a histogram on
observedtime for all observations.

Any suggestions on how to solve this?

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