That should not be necessary. In fact, I suspect it won't help at all.
If your original date-times are both consistently measured, the difference has the same units but does not have the same interpretation. It should be as simple as that. The key is that Stata just does not know what the differences mean.
Nick
[email protected]
moleps islon
Thank you Nick. This is indeed the case. I'll have another look at it
when I get back from work. Maybe if I instead code the time according
to date in addition I'd get the correct elapsed time ? ie I add
another day to the measurements after midnight.
On Tue, Dec 22, 2009 at 12:48 PM, Nick Cox <[email protected]> wrote:
> As I understand it, you have subtracted one date-time from another, but the result is not itself a date-time. It is an elapsed time, and Stata lacks any support specific to elapsed times. So, for example, 1 (elapsed) day and 2 (elapsed) days look identical in terms of clock time, as you already know.
>
> . di %tc_HH:MM:SS 24 * 60 * 60 * 1000
> 00:00:00
>
> . di %tc_HH:MM:SS 48 * 60 * 60 * 1000
> 00:00:00
>
> Conversely, the difference between 21 December 2009 and 22 December 2009 is not as indicated by
>
> . di %d mdy(12,22,2009) - mdy(12,21,2009)
> 02jan1960
>
> But just 1 day.
>
> In short, applying date-time formats to elapsed times at best tells only part of the story and at worst gives you nonsense. That shouldn't be a surprise when you think about it.
>
> For elapsed times, you need to create your own code (setting aside earlier user-written efforts best consigned to history).
>
> In essence, Stata carries no knowledge forward of how your variables were calculated. As I guessed earlier in the thread, you assigned a format that is no use for graphing, as it does not distinguish elapsed times except in terms of what a clock would show.
>
> I asked earlier for you to -summarize- the values of your variables, but I've not seen any results. From your graph it seems that the data fall into two distinct subsets, times less than 1 day and times more than 1 day. I can't suggest why that is, but only looking at your data closely can tell you if there is some error or this does in fact make sense.
>
> As I suggested earlier, it is likely that you need to create your own axis labels, using a conversion from milliseconds to hours. -mylabels- from SSC is there to help.
*
* 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/