Hi,
I work in research and handle merged data files received monthly. Each data set includes approximately 1000 rows of data per month, covering a period of ~two years. Each month, the merged file is updated with the latest months data (an additional 1000 rows).
I would like to create a few time variables and group the data by:
- Latest 3 months
- Rolling 3 months
- Rolling 6 months
- By quarter (following the calendar)
In the SPSS file, I have a variable named MONTH, which is numeric and sequentially labels each month (1 for the first month, 2 for the second, and so on). These months are labeled as Oct 2022 (1), Nov 2022 (2), up until the latest months May 2024 (20).
Currently, I manually create new variables each month. For instance, for a 3-month moving average, I create a new variable called Moving_average_20 (labeled as Moving average - May 2024) and use If\F statements to assign a value of 1 for the last three months and 0 otherwise.
I use a similar approach for the other time variables. Is there any SPSS syntax that can automate this process?
Many thanks
------------------------------
Amanda Eriksson
------------------------------