I'm a new SPSS user, and have a slightly odd-ball problem that I'm trying to code…
I need to define one variable based on the values within a different record.
To make this more concrete, here is the example of what I want to do:
> The dataset starts with two variables: Date and Todays_Rainfall.
> I would like to create a new variable called Yesterdays_Rainfall.
> Yesterdays_Rainfall will equal the value in Todays_Rainfall from the record that has a date one day prior.
In more general terms:
> For the ith record: Yesterdays_Rainfall[Date=i] = Todays_Rainfall[Date=i-1]
> I just need to know how to do the indirect referencing, after that I can figure out the looping to make SPSS do what I'm looking for.
A couple notes:
1) The example above is my most simple example. I have about a dozen variables that need to be defined this way, some are direct copies while others are more complicated (averages over the past week, values from the previous wednesdays, etc etc)
2) I want this as a script, because the code will be reused approx yearly and manual cut-pasting is time consuming.
3) One workaround *could* be to use excel, but I don't want to because Excel is icky.
4) A better workaround *could* be to create dummy datasets and then merge them. But this introduces many opportunities for things to go wrong if I have to do it a half-dozen times… This is my back-up solution, but I'd much prefer a more direct and elegant solution.