Home > FAQ > Data Manipulation > Event histories (status histories) > Cleaning or editing an event history > Determining start events, stop events and not service related events

Determining start events, stop events and not service related events

We need to use the event codes in the event history to determine what events are start, stop or non-calculation events. 

For purposes of this discussion, we are assuming the event history is stored in a 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 &
Code:= #VALUE EventHistory &
; Don't assign the effective dates of the event history into a field called start
; (e.g., Start_DT)! That's confusing because we are working with events that START
; service and events that STOP service; many people would assume that Start_DT
; only contains the effective dates of the start events.

IsStartEvent:= Code #IN (10, 11, 12) & ; i.e., #IN (all the start event codes)
 
IsStopEvent:= Code #IN  (31,41,51,61) & ; i.e., #IN (all the stop event codes)
IsStopEvent:= Code #NOTIN (10, 11, 12) & ; i.e., #NOTIN (all the start event codes)
; If we only have start and stop events (and we don't have to worry about non-service
; related events), the list of the start event codes is smaller than the list
; of stop event codes, so it's simpler to use #NOTIN and list the start event codes


NotAnEvent:= Code #IN (list of non-service related codes) &
NotAnEvent:= #NOT (IsStartEvent #OR IsStopEvent) &
; this is the simplest way if we've already identified the start and stop events
 
Keep in mind, the problem with using codes in an expression is that if someone adds a new code, then someone also has to remember to add the new codes to #IN and #NOTIN in any expression that uses them. Otherwise, the new codes can break these expressions. You could easily add a User-defined "data-based" error message in the Census Specification to check that the event history only contains the expected codes (i.e., someone didn't add a new code).