1

Can someone help me with a way to convert monthly timeseries to quaterly time series or should a quaterly data be loaded for forecasting in SPSS?

The Monthly dataset has multiple variables along with the Year and Month. In the quarterly dataset, i wish the 1st case of variable "id" to be replaced by the average of 1st 3 cases of the monthly dataset, 2nd case of variable "id" in quarterly dataset must be equal to the average of 4th, 5th and 6th cases of the same variable in the monthly dataset and so on. This is done to create a quarterly dataset which will then be used for forecast Analysis.

Please assume, all the variables are scale variables (although the names doesn't comply with the properties :P)

user10579790
  • 333
  • 1
  • 10
  • Please add some sample data and and more explanation about what you are trying to do. An example of the result data will also be very helpful – eli-k Feb 06 '19 at 09:44
  • Hey, I have edited my question for more clarification. – user10579790 Feb 06 '19 at 13:45
  • the examples you posted are not very helpful (I know how a dataset looks, wanted to know how YOUR dataset looks), but The new explanation makes it clearer, will try to answer – eli-k Feb 06 '19 at 14:04

1 Answers1

1

What you want (correct me if i'm wrong) is to create an average of each three months into one quarter. So first we'll create a Quarter variable and then use in in an aggregation:

compute Quarter=trunc((month-1)/3)+1.
* this can also be done like this: 
* recode month (1 2 3=1)(4 5 6=2)(7 8 9=3)(10 11 12=4) into Quarter.

dataset name byMonth.
dataset declare byQuarter.
aggregate /outfile=byQuarter /break=Year Quarter ...Other_grouping_variables ... 
        /var1 var2 ... your_scale_variables ....=mean(var1 var2 ...your_scale_variables...).
dataset activate byQuarter.

You now have two datasets - one is your original by month, the other is the new one by quarter.

eli-k
  • 10,898
  • 11
  • 40
  • 44
  • Hey, thanks! I have replaced the byMonth with my original dataset and variables too. On running this code, an error is displayed "Dataset byQuarter has no data". Any idea why this would happen? – user10579790 Feb 06 '19 at 14:46
  • you have to put the right variables in the right place in the code of course. no error messages? post your fixed code here, i'll take a look – eli-k Feb 06 '19 at 14:53
  • `COMPUTE Quarter=TRUNC((MONTH_-1)/3)+1. EXECUTE. DATASET NAME KV. DATASET DECLARE byQuarter. AGGREGATE /OUTFILE='byQuarter' /BREAK=YEAR_ Quarter /KV.1 TO KV.126=MEAN(KV.1 TO KV.126). DATASET ACTIVATE byQuarter.` – user10579790 Feb 06 '19 at 15:11
  • Is there a `select` command in the syntax before this part, that might have emptied the dataset before the aggregation? try `freq quarter.` after you calculate it, to see there actually are cases in the data. If it looks ok, I suggest you start a new question with this – eli-k Feb 06 '19 at 15:18
  • There in no `select` command and the `freq quarter` gives the correct output. – user10579790 Feb 06 '19 at 15:36
  • :/ please start a new question with your code and a sample of the data you are using (best practice for that is to use `data list` command, which enables other users to re-create your sample on their machine - look at two examples in my answer [here](https://stackoverflow.com/questions/52414499/merging-2-files-without-a-common-key/53101686#53101686)) – eli-k Feb 06 '19 at 15:56
  • say, now that your problem with the aggregate command is resolved - is this question solved? – eli-k Feb 18 '19 at 06:22
  • Hey, yes! Thanks a lot. – user10579790 Feb 18 '19 at 13:44