Hi everyone, I am hoping someone can help me! I am working with data that have multiple observations per person, each with a different reason for the observation. The pattern must start with a reason of 1 or 3, have one or more observations with a 4 or 5, and end with an observation of a 1 or 3. The number of observations within a pattern can vary and this pattern may occur multiple times for one person. I have the end of the pattern I am looking for flagged but I now need to flag the start of the pattern I am looking for as well as populate that observation with the number of 4/5's that follow prior to the pattern ending 1 or 3 observation. I have put together some fake numbers in an effort to help explain what I am looking for. I am using SAS 9.4. LocationID PersonID Date Reason Cycle_end(have) Cycle_start(need) Count(need) 1 1 1/2/2014 01 1 3 1 1 1/3/2014 04 1 1 1/4/2014 05 1 1 1/5/2014 04 1 1 1/6/2014 01 1 1 1 1/7/2014 03 1 3 1 1 1/8/2014 04 1 1 1/9/2014 05 1 1 1/10/2014 04 1 1 1/11/2014 01 1 1 1 1/12/2014 09 1 2 1/13/2014 01 1 2 1/14/2014 09 1 2 1/15/2014 01 1 2 1 2 1/16/2014 04 1 2 1/17/2014 04 1 2 1/18/2014 01 1 1 2 1/19/2014 01 1 2 1 2 1/20/2014 04 1 2 1/21/2014 05 1 2 1/22/2014 03 1 2 3 1/23/2014 01 2 3 1/24/2014 04 2 3 1/25/2014 04 2 3 1/26/2014 09 2 3 1/27/2014 01 1 2 2 3 1/28/2014 04 2 3 1/29/2014 05 2 3 1/30/2014 03 1 2 4 1/31/2014 01 2 4 2/1/2014 04 2 4 2/2/2014 04 3 5 2/3/2014 04 3 5 2/4/2014 04 3 5 2/5/2014 01 1 3 3 5 2/6/2014 04 3 5 2/7/2014 04 3 5 2/8/2014 04 3 5 2/9/2014 03 1 3 6 2/10/2014 06 3 6 2/11/2014 08 Thanks for any help!!
... View more