Hi. I have data on hospital visits for the period of Oct 1, 2022 - Feb 28, 2023. The visits have the date of visit (checkin_date) and time of visit. Time of visit is captured by two variables - appt_time and day_time. appt_time follows a 12 hour clock and day_time uses AM/PM - to together indicate the exact time of visit

I want to do two things:
1. Generate a week variable where Oct 1-7 is week 1, Oct 8-14 is week 2 and so on. However, there may be missing days in the checkin_date variable and I don't want days skipped in the week variable, i.e. Oct 1-7 has to be week 1 even if there is Oct 5 missing in the data.
2. Generate a time of day variable where appointments are categorized as "morning" if before 12 pm, "afternoon" if between 12-4 pm, and "evening" if after 4 pm.

I've been struggling on these two and would very much appreciate any guidance here.

Code:
input str13 Hospital int checkin_date double appt_time str2 day_time
"Main Campus" 22919      -1.8934524e+12 "PM"
"Main Campus" 22919      -1893452340000 "PM"
"Main Campus" 22919      -1893452340000 "PM"
"Main Campus" 22919      -1893452340000 "PM"
"Main Campus" 22919      -1893452160000 "PM"
"Main Campus" 22919      -1893452160000 "PM"
"Main Campus" 22919      -1893452040000 "PM"
"Main Campus" 22919      -1893452040000 "PM"
"Main Campus" 22919      -1893452040000 "PM"
"Main Campus" 22919      -1893451980000 "PM"
"Main Campus" 22919      -1893451980000 "PM"
"Main Campus" 22919      -1893451920000 "PM"
"Main Campus" 22919      -1893451920000 "PM"
"Main Campus" 22919      -1893451860000 "PM"
"Main Campus" 22919      -1893451740000 "PM"
"Main Campus" 22919      -1893451680000 "PM"
"Main Campus" 22919      -1893451680000 "PM"
"Main Campus" 22919      -1893451440000 "PM"
"Main Campus" 22919      -1893451380000 "PM"
"Main Campus" 22919      -1893451380000 "PM"
"Main Campus" 22919      -1893451380000 "PM"
"Main Campus" 22919 -1893451320000.0002 "PM"
"Main Campus" 22919      -1.8934512e+12 "PM"
"Main Campus" 22919      -1893450960000 "PM"
"Main Campus" 22919      -1893450960000 "PM"
"Main Campus" 22919      -1893450960000 "PM"
"Main Campus" 22919      -1893450960000 "PM"