Home > FAQ > Data Manipulation > Event histories (status histories) > Cleaning or editing an event history > Add the decrement date to the event history

Add the decrement date to the event history

When performing a calculation, often the final decrement date isn’t in the event/status history because the participant hasn’t actually terminated or retired yet (so it's not in the database's event history). When using events to edit data in a data default, or to transform hours/salary in transformation expression, it’s incredibly useful to have the decrement date in the event/status history.

Note: Sometimes, the last event is a stop event, and that makes it unnecessary to add the decrement date to the event history.

For purposes of this discussion, we are assuming the event history is stored in coded effective date array called EventHistory, where the start event codes are 10, 11, and 12, and the stop event codes are 31, 41, 51, and 61.

 

EV_DT:= #START EventHistory & ; all event dates
Code:= #VALUE EventHistory & ; all event codes
 
LastEvent:= #GETVALUE Code & ; returns the last non-zero value in Code
IsLastEventStop:= LastEvent #IN (31, 41, 51, 61) & ; use all the stop event codes 
LastEvent_DT:= #GETVALUE EV_DT & ; returns the last non-zero value in array EV_DT
; Get the effective date of the last event, so we can determine if
; the decrement date is in the event/status history (assumes zero is not
; a valid event code)

 
DEC_DT:= #DODEC#NOT IsLastEventStop &
; if the last event in EventHistory is a stop event, then DEC_DT is set to zero; 
; otherwise DEC_DT contains the decrement date

 
12 #ARRAY (EV_DT,Code,DEC_DT,31) ; append decrement date and code 31 (code for decrement or termination) to event history 
; (1) #ARRAY always drops rows with a zero effective/start date from the final array.
; (2) If the decrement date is in EventHistory or the last event was a stop event,
;     then DEC_DT is zero and the decrement/termination code will be dropped by #ARRAY