Good morning everyone !
I have a problem of calculating the decile by group.
Here is the datset that I use:
I want to collapse the education level and other demographics, by whether be promoted or not.
but now the data stucture is like below so I need your kindly help with how to achieve the goal :

id time edu occupation
1 1 3 1
1 2 3 1
1 3 3 2
1 4 3 2
2 1 5 2
2 2 5 2
2 3 5 4
3 1 4 2
3 2 4 2
3 3 4 2


for individual 1 and 2, because they are both promoted (id1: from occupation 1 to 2; id2: from occupation 2 to 4) during the sample period, so they are catogorized as "promoted" group, and 3 is not promoted during this time, so it is catogorized as "non-promoted" group.

Now I'd like to know the mean education level for both groups. So the mean edu is (3*4+5*3)/7 for "promoted" and (2*3)/3 for "non-promoted" group.
It would be very nice if you could tell me how to write the code !!
Thanks ^_^