Hi Family,
I am currently working on a dataset in a roster format that contains timestamps, and I am seeking assistance with converting these timestamps to the required format.
Despite the attempt in creating three new variables, I continue to encounter a "type mismatch" error while attempting to use the collapse command to sum the time differences by unique ID.
This was the little that I know but It did not work out for me.
I would greatly appreciate your help in resolving this issue.
I have attached the dataset for your reference.
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(MRESPONSE_ID START_TIME_SECS STOP_TIME_SECS)
1 1681182712 1681182762
1 1681183070 1681183080
1 1681183410 1681183423
1 1681183467 1681183472
2 1681184993 1681185138
2 1681185312 1681185464
2 1681185708 1681185926
end
Thank you very much in advance.
Sham
I am currently working on a dataset in a roster format that contains timestamps, and I am seeking assistance with converting these timestamps to the required format.
Despite the attempt in creating three new variables, I continue to encounter a "type mismatch" error while attempting to use the collapse command to sum the time differences by unique ID.
This was the little that I know but It did not work out for me.
- gen start_time_stata = clock(START_TIME_SECS, "YMDhms") /// to convert the start timestamp
- gen end_time_stata = clock(STOP_TIME_SECS, "YMDhms") ////to convert the stop timestamp
- gen time_diff = end_time_stata, start_time_stata, "seconds") ////to get the difference
- collapse (sum) time_diff, by(MRESPONSE_ID) /////To obtained the actual Interview duration for each case(1 and 2)
I would greatly appreciate your help in resolving this issue.
I have attached the dataset for your reference.
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(MRESPONSE_ID START_TIME_SECS STOP_TIME_SECS)
1 1681182712 1681182762
1 1681183070 1681183080
1 1681183410 1681183423
1 1681183467 1681183472
2 1681184993 1681185138
2 1681185312 1681185464
2 1681185708 1681185926
end
Thank you very much in advance.
Sham
Comment