Matching an event to a week ID

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

Posts: 1
Joined: Wed Feb 17, 2016 1:50 pm

Matching an event to a week ID

Postby gzrcm » Wed Feb 17, 2016 2:14 pm

Hello forum,

This is my first post so I will try to be as comprehensive as possible. I am currently working with two data sets. One is a weekly snap shot of costs in which each week has a numeric identifier starting in August 2011 to December 2015 (203 weeks). Each snap shot also has a date in which is was taken ie; (04/01/2013). I have used a lag function to compute a snap date out variable that gives me week intervals, this was done to fit the code below. My second data set has a list of events that contain the date in which is the event took place in the same format as previously specified. I am attempting to group events in the second data set into which snap shot interval the belong in the first dataset, either by date or by week identifier.

I have attempted using the following code posted on Raynald's SPSS tools in 2010:

The code I have adapted from the guide is below.

This is also a quick guide to equivalent variables between he guide and my code:
file1= 3763EventsMatch.sav
file2= 3763DateMatch.sav

Code: Select all

GET FILE='O:\Test\Test Data\t3763\3763EventsMatch.sav'. 
VECTOR dt(3). 
COMPUTE dt(idx)=Doc.Date.
   /dt1 TO dt3=FIRST(dt1 TO dt3). 
MATCH FILES /FILE= "O:\Test\Test Data\t3763\3763DateMatch.sav"
   /BY id.
VECTOR dt=dt 1 TO dt3.
LOOP #idx=1 TO 3. 
    DO IF RANGE(dt(#idx),snap_date_in,snap_date_out).
        COMPUTE idx=#idx.
    END IF. 
I keep getting an error at the Aggregate stage where I receive this message;

Code: Select all

>Warning # 525
>An attempt was made to store a value into an element of a vector the subscript
>of which was missing or otherwise invalid.  The subscript must be a positive
>integer and must not be greater than the length of the vector.  No store can
I am unable to make the vector function. However, I am also not convinced that this code may be the most efficient solution. Any help or advice on resolving the error or an alternative syntax would be greatly appreciated.


Who is online

Users browsing this forum: No registered users and 1 guest