clear
set obs 20
gen x = 1
gen id = 1 in 1/10
replace id = 2 in 11/20
replace x = x + 5 in 6/10
replace x = x + 5 in 16/20
set obs 20
gen x = 1
gen id = 1 in 1/10
replace id = 2 in 11/20
replace x = x + 5 in 6/10
replace x = x + 5 in 16/20
This is just an example; more generally, I have a dataset with minute-level data that crosses the day delimiter, and I would like to identify a night (e.g. starting at 10 PM and ending at 6 AM). Since I have minute-level data, there are breaks where on the same date the difference between times is higher than 1 minute (e.g. jumping from 6AM to 11PM - the start of a new night). I thought of using these jumps to identify the nights since dates as groups, in this case, are useless (because they encompass both the beginning of the next night and the end of the previous one).
Any ideas are appreciated.
0 Response to Break in consecutive values to identify groups
Post a Comment