Hello All! I am trying to write a loop that will cycle through all mothers in my dataset and flag each day there was a heatwave in their gestational period. I have temperature measure for each day for a three year period. There is a gestational start date and gestational end date for each mother within this 3 year period. If a temperature is higher than a certain threshold it should be flagged as a heatwave. For example, if I am using greater than the 90th percentile any day with a temperature greater than the 90th percentile of all the temperatures over the three year period is a heatwave. I would like to output a dataset that has mothersID and the sum of each flagged heatwave day within the gestational period for each mother: My data looks like this: MotherID gest_start_date Gest_end_date 1/1/13 1/2/13 1/3/13..... 12/31/16 1 5/2/13 2/4/14 81 82 79 91 2 1/18/14 9/2/14 71 73 78 73 3 2/20/13 10/15/13 82 85 81 82 4 8/12/15 5/12/16 75 76 77 78 Any help will be much appreciated!
... View more