(no subject)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

Butler, Deborah {FLNA}
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
Reply | Threaded
Open this post in threaded view
|

Re: Looping to select question

Maguin, Eugene
Debbie,

Note: In an off-list exchange, Debbie confirmed that her incoming data set
is structured as ONE record per case with the following organization:

Location,
Product,
Orderdate,
effective_start_date1 through effective_start_date21,
end_date1 - end_date21,
source1 through source21,


You'll have to try this out and report back if there are errors.

Vector start=effective_start_date1 to effective_start_date21/
   end=end_date1 to end_date21/
   source=source1 to source21.
*  I assume that orderdate will never be greater than the last ending date
*  and never less than the first starting date.
*  I assume that an order date can never be between an ending date and the
*  following date.
*  I assume that an ending date and the following start date will never be
*  the same date.
*  I also assume that the number of ending dates, starting dates and sources

*  always match.
Loop #i=1 to 21.
+  do if (start le orderdate and end ge orderdate).
+     compute validsource=source(#i).
+  else.
+     break.
+  end if.
End loop.



Gene Maguin