If I had an additional information that -groupid- goes from 1 to G,
would something like this work? I am sure this can be optimized, but I
wonder if my Mata thinking is reasonable. At least this code avoids
sorting operations.
selectvar = J(rows(id),1,.)
for(g=1;g<=G;g++) {
// take a subview corresponding to value of g
selectvar = ! ( id - J(rows(id),1,g) )
st_select(thisy=.,y, selectvar)
st_select(yy2=.,y2,selectvar)
yy2[,]=J(rows(yy2),1,colmean(thisy))
}
-panelsetup- is probably a more elegant solution, I've never tried it!
--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: Please do not reply to my Gmail address as I don't check
it regularly.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/