I would like to generate a new variable whose value is the average of
other individual in the same group as the concerned individual. For
example, for the first individual (ID=1), this will be: (7+9+8)/3= 8.
For the 6th individual, this will be (3+9)/2=6 and so on.

I would highly appreciate if someone could suggest me a solution for
this.
Thanks and Have A Great Day!
Sincerely yours,