I am trying to figure out if an event occurred in the three consecutive previous years by month. For example:
Item Type Month Year Hat S May 2015 Shirt P June 2015 Hat S June 2015 Hat S May 2016 Shirt P May 2016 Hat S May 2017
Assuming I am in 2018, I am interested in seeing what item was purchased/sold for three consecutive years in the same month. Hat was sold in May in 2015, 2016, and 2017; therefore, I would like to identify that. Shirt was purchased in June 2015 and May 2016. Since this is different months in consecutive years, it does not qualify.
Assuming I am in 2019, nothing qualifies since nothing was purchased in 2018.
Essentially, I want it to be able to look back 3 years and identify those purchases/sales that reoccurred in the same month each year, preferably with an indicator variable.
Aucun commentaire:
Enregistrer un commentaire