Grouping Cases on SPSS by Date

#1
Hi,

I am trying to come up with some syntax for the following query but have so far been unsuccessful.

Example Table:

Person DateSpec Primary Record
Person1 24/05/2015 1
Person1 02/06/2016 0
Person1 02/06/2015 0
Person1 01/01/2016 0
Person1 04/02/2016 0
Person2 12/09/2015 1
Person2 21/10/2015 0
Person2 12/03/2016 0
Person2 20/03/2016 0



I have grouped all the cases by various identifiers so that they are now grouped togethPerson1er. the 'PrimaryRecord' variable is used to separate each person.
The next task I would like to do is further separate these individuals by 'DateSpec'. This is where I have run into difficulty. I would want to group it so that all dates for one individual that fall within 6 weeks (42 days) of the current PrimaryRecord are grouped together. For example, Person1 would have two different groups, first three rows would be grouped together and then the following two rows would be classed as separate.

Ideally I would like this to follow the same primary record pattern as above so that person1 would then have two 1s next to them. Or if anyone out there has any sort of way of generating an unique ID to group these together that would be even better.

Any help or advice on this would be greatly appreciated, even if its to say it cant be done.

Thanks in advance and feel free to fire questions at me.