Page 1 of 1

creating grouped mean variable

Posted: Fri Oct 03, 2025 12:49 pm
by srk80
Hi,

I would like to have a functionality similar to ave in base R to create a grouped mean variable. I have a dataset with a continuous variable x and group. Now I want to create a new variable where all observations in a particular group have the same mean. How to do?

Re: creating grouped mean variable

Posted: Fri Oct 03, 2025 11:47 pm
by jonathon
you can achieve this with computer/transformed variables:

x - VMEAN(x, group_by=group)

jonathon