I have a dataset which includes the following two variables (it includes more, but for simplicity's sake, I'll just discuss these two): Date and Hot
Date is a SAS date variable and Hot is a binary (0,1) variable.
I'd like to read the dataset and have a count variable which counts the number of days in a row where the Hot variable is a 1.
This is an example of what my data look like:
Date Hot
14JUN2010 0
15JUN2010 1
16JUN2010 1
17JUN2010 0
18JUN2010 1
19JUN2010 1
20JUN2010 1
21JUN2010 0
This is an example of what I would like my data to look like:
Date Hot HotDays
14JUN2010 0 0
15JUN2010 1 1
16JUN2010 1 2
17JUN2010 0 0
18JUN2010 1 1
19JUN2010 1 2
20JUN2010 1 3
21JUN2010 0 0
I've tried a number of different things, none of which work. I've read up on the retain statement and group by processing, but I haven't figured out how to adapt those strategies to counting sequential dates by binary variable.
Thanks for your help.