assign_tseg_internal function

Internal function that adds segment numbers to observations