I have event date data where there are multiple eventdates.
I'd like to create a grouping variable based on the past 24 months starting in 2020.
Given their are multiple events on the same date I can't tsset the data without first collapsing it.
I posted this question for years and figured out an easy fix. I don't want to have to write 48 lines of code and generate 48 groups. I imagine there is a loop I could write.
ro_n = unique identifier
eventdate year ro_n weight
18jun2017 2017 2 6
18jun2017 2017 2 5
29jan2020 2020 2 3
29jan2020 2020 2 1
29jan2020 2020 2 14
29jan2020 2020 2 6
29jan2020 2020 2 2
29jan2020 2020 2 6
29jan2020 2020 2 9
29jan2020 2020 2 15
29jan2020 2020 2 4
26nov2022 2022 3 15
26nov2022 2022 3 10
26nov2022 2022 3 6
26nov2022 2022 3 14
26nov2022 2022 3 7
29oct2023 2023 4 2
29oct2023 2023 4 13
I'd like to create a grouping variable based on the past 24 months starting in 2020.
Given their are multiple events on the same date I can't tsset the data without first collapsing it.
I posted this question for years and figured out an easy fix. I don't want to have to write 48 lines of code and generate 48 groups. I imagine there is a loop I could write.
ro_n = unique identifier
eventdate year ro_n weight
18jun2017 2017 2 6
18jun2017 2017 2 5
29jan2020 2020 2 3
29jan2020 2020 2 1
29jan2020 2020 2 14
29jan2020 2020 2 6
29jan2020 2020 2 2
29jan2020 2020 2 6
29jan2020 2020 2 9
29jan2020 2020 2 15
29jan2020 2020 2 4
26nov2022 2022 3 15
26nov2022 2022 3 10
26nov2022 2022 3 6
26nov2022 2022 3 14
26nov2022 2022 3 7
29oct2023 2023 4 2
29oct2023 2023 4 13
Comment