I have read the documentation but I still do not understand why I can npt convert my string variable to a date variable.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long patientid str23(AdmissionTime DischargeTime) str29 datetime str22 value 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:22:49.430000000" "64" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:24:49.440000000" "64" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:26:49.460000000" "64" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:28:49.470000000" "64" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:30:49.470000000" "65" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:32:49.470000000" "59" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:34:49.490000000" "66" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:36:49.490000000" "65" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:38:49.490000000" "63" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:40:42.980000000" "62" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:42:42.980000000" "59" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:44:43" "60" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:46:43" "62" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:48:43" "60" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:50:43.010000000" "59" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:52:43.030000000" "75" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:54:43.040000000" "77" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:56:43.040000000" "73" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 14:58:43.040000000" "75" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:00:43.060000000" "67" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:02:43.060000000" "55" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:04:43.060000000" "52" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:06:43.060000000" "56" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:08:43.070000000" "55" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:10:43.070000000" "57" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:12:43.090000000" "59" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:14:43.090000000" "58" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:16:43.110000000" "57" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:18:43.110000000" "30" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:20:43.110000000" "30" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:22:43.110000000" "46" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:24:43.120000000" "57" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:26:33.320000000" "54" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:28:33.340000000" "70" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:30:33.340000000" "70" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:32:33.340000000" "72" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:34:33.340000000" "78" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:36:33.340000000" "66" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:38:33.340000000" "67" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:40:33.360000000" "65" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:42:33.370000000" "65" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:44:33.370000000" "66" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:46:33.390000000" "67" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:48:33.390000000" "65" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:50:33.390000000" "68" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:52:33.400000000" "53" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:54:33.420000000" "42" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:56:33.430000000" "55" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 15:58:33.430000000" "57" 776 "2005-05-23 12:35:00.000" "2005-05-27 14:20:00.000" "2005-05-23 16:00:33.430000000" "61" end
Above is an excerpt of my dataset. I can convert the the first two variables;
Code:
gen double AdmissionTime2=clock(AdmissionTime, "YMD hms") format AdmissionTime2 %tcCCYY-NN-DD_HH:MM:SS.sss
Code:
gen double DischargeTime2=clock(DischargeTime, "YMD hms") format DischargeTime2 %tcCCYY-NN-DD_HH:MM:SS.sss
However for the variable datetime I get missing values, except for the 3 observations that are bolded when I use the same code;
Code:
gen double MAP_time=clock(datetime, "YMD hms") format MAP_time %tcCCYY-NN-DD_HH:MM:SS.sss
/Jesper Eriksson
0 Response to Date problem. Again...
Post a Comment