I am trying to compute call duration from subtracting two time periods in Stata but I get resultant incorrect time difference between the two variables. I have looked online but was unable to fix the issue. The "CallDuration" variable that I have has constant 12 hours added to it. I am trying to subtract 12 hours (the variable for this is "twlhour") from my "CallDuration" variable but the answer seems to be incorrect and unintuitive. Please tell me how to fix this problem.
This is my sample data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(CalledNumber Date) double(Time CallDuration) float(twlhour call_dur) 15000 21304 -1893384240000 -1893455984000 4.32e+07 -1.893499e+12 15000 21304 -1893384240000 -1893455925000 4.32e+07 -1.893499e+12 15000 21304 -1893384300000.0002 -1893455891000 4.32e+07 -1.893499e+12 15000 21304 -1893384300000.0002 -1893455950999.9998 4.32e+07 -1.893499e+12 15000 21304 -1893384360000 -1893455985999.9998 4.32e+07 -1.893499e+12 15000 21304 -1893384660000 -1893455914000 4.32e+07 -1.893499e+12 15000 21304 -1893384660000 -1893455677999.9998 4.32e+07 -1.893499e+12 15000 21304 -1893384720000 -1893455813000 4.32e+07 -1.893499e+12 15000 21304 -1893384720000 -1893455954999.9998 4.32e+07 -1.893499e+12 15000 21304 -1893384840000 -1893455768000.0002 4.32e+07 -1.893499e+12 end format %tdnn/dd/CCYY Date format %tchh:MM_AM Time format %tchh:MM:SS CallDuration format %tcHH:MM:SS twlhour format %tcMM:SS call_dur
gen twlhour = 60*60*1000*12 // making a 12 hour variable
format twlhour %tcHH:MM:SS // formating
gen call_dur = CallDuration - twlhour //
format call_dur %tcMM:SS
Thanks anyways
0 Response to Incorrect results when subtracting time
Post a Comment