I have a longitudinal dataset with participant age and a variable to show the age at which a participant experienced an event (0/1) as follows.
id  age  event
 1    0     0
 1    1     0
 1    2     0
 1    3     0
 1    4     0
 1    5     0
 2    0     0
 2    1     1
 2    2     1
 2    3     1
 2    4     1
 2    5     1 
 3    0     0
 3    1     0
 3    2     0
 3    3     1
 3    4     1
 3    5     1
Based on whether the event never happened (0) or it happened before the age of 2 yrs (1) or after the age 2 yrs (2), I want to generate a new variable called timing and assign each participant to a group (0,1,2) as follows:
id  age  event  timing  
 1    0     0      0
 1    1     0      0
 1    2     0      0
 1    3     0      0
 1    4     0      0
 1    5     0      0
 2    0     0      1
 2    1     1      1
 2    2     1      1
 2    3     1      1
 2    4     1      1
 2    5     1      1
 3    0     0      2
 3    1     0      2
 3    2     0      2
 3    3     1      2
 3    4     1      2
 3    5     1      2
I don't have great coding skills and would really appreciate if anyone could assist.
 
     
     
    