Array handling can consume a lot of processing (for larger data volumes) but i/o has always been the issue for smaller platforms. For the systems where cpu time is under pressure, techniques have developed to deal with this kind of data model in different ways. For example this pseudo code would mark all weeks of a TRT (treatment?) in one statement, rather than mark each week of treatment separately :
clear buffer (of 150 weeks buffer= repeat( 'N', 149) )
do until last of customer/ID
get next event data
determine start week(e.g. int(stdate/7) )
determine end week (e.g. ceil(endDate/7) )
adjust start and end-week to be within the buffer( within the 150 weeks)
determine duration of event ( endw-startw )
flag buffer at startWeek for duration[pre] substr( buffer, startW, trt_durn ) = repeat( 'Y', trt_durn ) ;[/pre] repeat until last of customer/id
write buffer
this could involve overlaying the memory area of an array of 150 one character elements when if the flags need to be treated as separate variables.
I made no allowance for aligning week start to Sunday/Monday/startInterval, because I'm not sure how much impact it would have.
The model would be simpler and could operate at the day-level and wrap-up weeks later, if the TRTdate spans less than 89 years (1jan2000 +max buffer of days=32767) = 17Sep2089
If the target platform for the data model is not cpu constrained, then the methods offered by Scott and Flip may be the best alternative.
PeterC
... View more