Changing dates to num days

If I understand you correctly, it would be something like this:

library(dplyr)

your_data_frame %>%
    group_by(SID) %>% 
    mutate(day_number = row_number())

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.