Hi. I have a time variable in a 24-hour HH:MM format and want to categorize it as - morning: <12:00; afternoon >=12:00 & <17:00; and, evening: >=17:00. However, my code below fails. Any help in doing so will be much appreciated
Code:
*code gen byte timeofday=. replace timeofday=1 if appt_time_of_day<12:00 replace timeofday=2 if appt_time_of_day>=12 & appt_time_of_day<17 replace timeofday=2 if appt_time_of_day>=17 *Data input double appt_time_of_day 30600000 32400000 43200000 53700000 47700000 29700000 38700000 35100000 33300000 39600000 42300000 37800000 41400000 34200000 36900000 28800000 45000000 36000000 40500000 35100000 37800000 39900000 36000000 42600000 34200000 36900000 51300000 50400000 31500000 40200000 29700000 28800000 47700000 52200000 48600000
Comment