I have been working for 2 + years with data generated from a custom app seeking improvement in treatment of Parkinson's disease. Data are merged from 3 streams, tsset with 1 minute intervals, every day is a panel. Data elements from the app include patient reported symptoms, time, type and quantity of dopamine and related drugs (Rytary and Requip) and other variables. The second stream is biometric data reported by the Apple watch: heart rate, basal and active energy, steps, and the like. The third stream emanates from a Scilab model that estimates concentrations of drugs based on a state space technique.

Drugs are supposed to be taken every 4 hours, at 02 06 10 14 18 and 22 hours, but actual times vary. I seek to establish subpanels based on a new variable aux_axis whose value is zero 60 minutes before a non_zero instance of time_Ry, the time each Rytary is taken, and is 180 120 minutes after actual pill time.

My general approach has been to use subgroup techniques described in Mitchell, MN, "Data Management Using Stata", 2010, Chapter 7, with direct addressing of subscripts, but I haven't succeeded. Is there a better approach to this goal?