Hi, thanks for the help. I have a variable of precipitation (s2_precip_cm) and I'd like to create new variables that sum precipitation over various days. For instance, ppt_sum3 would be the sum of precipitation from day 1, the precipitation of the day prior, and the precipitation of two days prior. I was having trouble trying to write this in one code, so I've created a new dataset that lags precipitation by one day (s1n_lags). In this file, ppt_lag3 is the precipitation reading from three days prior to my observation. I was hoping that now I could sum across observations to obtain the correct variables. In this code, I was hoping that ppt_sum{i} = sum(ppt_lag{i-1} - ppt_lag1) would be equal (for i = 5) to ppt_sum5 = sum(ppt_lag4, ppt_lag3, ppt_lag2, ppt_lag1) and i = 6 would be equal to ppt_sum6 = sum(ppt_lag5, ppt_lag4, ppt_lag3, ppt_lag2, ppt_lag1). I'd like to do this for up to 37 observations. Thank you so much for your help!
... View more