18 Aug 09 14:16
I'm hoping there are some SPSS syntax programmers out here! I'll try to keep this short:
I have a data set with about 1.5 million people. The data set contains their prescription drug records from 2006. The data is set up this way:
Subj begin1 stop1 begin2 stop2...etc
1 1/12/06 2/24/06 1/30/06 3/28/06
1 2/25/06 3/29/06
1 3/30/06 4/20/06 5/15/06 6/15/06
2 1/20/06 3/20/06
where begin1 stop1 = the start & end dates of class 1 type of drug (there are 25 classes).
I need to create 3 new binary variables to reflect the amount of overlap in class of drug(30 days, 60 days, 90 days). Here is the macro I am working with:
DEFINE !OVLAP25 ().
!do !i=1 !to 24
!do !j=!i !to 25
!if (!j>!i) !then
compute #begin =max(!concat(begin,!i), !concat(begin,!j)).
compute #stop=min(!concat(stop,!i), !concat(stop,!j)).
if (#begin<#stop) #overlap25 =ctime.days(#stop-#begin).
if (#overlap25>=30) overlap25_30 =1.
if (#overlap25>=60) overlap25_60=1.
if (#overlap25>=90) overlap25_90=1.
The issue is, I need to make sure that the only overlap is within subject (e.g. overlap within subj = 1, within subj = 2, etc). Right now, it assess any overlap at all, regardless of subj #.
Is there a way to do this? Aggregate? Any help would be greatly appreciated!!!