Sorry, I need to correct the code just posted:
In Stata terms this is, with a group structure:
bysort group : gen newvar = sum(score)
by group : replace newvar = (newvar[_N] - score) / (_N - 1)
There could be at least one problem with
this, any missing values in -score-.
The extra wrinkle to cope with that is
something like
bysort group : gen newvar = sum(score)
by group : gen N = sum(score < .)
by group : replace newvar = (newvar[_N] - score) / (N[_N] - 1)
or like
bysort group : gen newvar = sum(score)
by group : egen N = count(score)
by group : replace newvar = (newvar[_N] - score) / (N - 1)
Nick
[email protected]
P.S. another way to do it
bysort group : egen newvar = sum(score)
by group : egen N = count(score)
by group : replace newvar = (newvar - score) / (N - 1)
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/