Astounding, I understand your point but as as with any study, there should be test candidates with effectively 0 drugs taken from start to end so you can use a change from 0 to 1 in the 1825 days array as a starting point nor the shift back from n to 0 as the end date.
There is also a chance that the minimum start_date is not equivalent to day1. Think the official study date starts on may01 but patients only came in to get drugs by may03 after being contacted on may01-may02.
Ultimately, there should be additionnal condition to the new array creation in case someone can have a start-end period less than 365 days yet still have drug count NE 0 between end date and the 365 days loop but I simply assumed that the drugs counted for the study were those prescribed for and by the study such that day{i} is uniformely 0 for all days not between start_date and end_date. Still, I agree that setting days to missing or some other code instead of 0 whenever the patient left the study early allows for more flexibility for data analysis which can be derived from start and end date.