Debbie:
Here is a vector and loop combination that will identify the number of
the start end pair that contains the order date:
*** sample data to illustrate.
*** case 2 has no match.
DATA LIST FREE /location product (2f8.0) orderdate eff_start1 TO
eff_start5 (6ADATE10) eff_end1 TO eff_end5 (5ADATE10).
BEGIN DATA
1 1 10/01/2005 08/10/2002 12/12/2003 01/22/2004 06/06/2005 09/25/2006
09/10/2002 12/13/2003 02/22/2004 10/10/2005 09/30/2006
2 1 05/11/2005 05/10/2006 06/12/2006 . . .
05/12/2006 06/13/2006 . . .
END DATA.
VECTOR x = eff_start1 TO eff_start5
/y = eff_end1 TO eff_end5
LOOP #i = 1 TO 5.
DO IF orderdate GE x(#i) and orderdate LE y(#i) .
COMP valid_nbr = (#i).
COMP real_start = x(#i).
COMP real_end = y(#i).
END IF.
END LOOP.
FORMAT real_start real_end (ADATE10).
EXECUTE.
Hope this goes toward what you want-- valid nbr is the number of
data-pair, and real_start and real_end contain the dates.
Note: this approach works with non-overlapping periods (end1< start2)
with dates in ascending order (start1 <start2). No time to experiment
with overlapping pairs-- have a good weekend.
--jim
-----Original Message-----
From: SPSSX(r) Discussion [mailto:
[hidden email]] On Behalf Of
Butler, Deborah {FLNA}
Sent: Friday, October 27, 2006 3:33 PM
To:
[hidden email]
Subject:
I've got history data that has effective_start_date1 through
effective_start_date21, end_date1 - end_date21, and source1 through
source21.
I'm trying to use this history data to pull the correct source for a
given product and location at the orderdate time. I have to find the
vector(#) pair where the orderdate
is between the effective start and end and then return the corresponding
source.
I've been trying to set up vectors, scratch variables, and loops but I
get some pretty strange results. I'm 99% positive I'm not setting it up
correctly.
My file is set up as follows:
location
product
orderdate
effective_start_date1 through effective_start_date21
end_date1 - end_date21
source1 through source21
I want the resulting variable
ValidSource(for that location, product, order date)
It should be elementary but I'm getting frustrated. Could someone
please help me out with this??
TIA!
Debbie Butler