[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: egen and Mata

From   "Stas Kolenikov" <>
Subject   Re: st: egen and Mata
Date   Wed, 16 Jul 2008 16:31:06 -0500

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)

-panelsetup- is probably a more elegant solution, I've never tried it!

Stas Kolenikov, also found at
Small print: Please do not reply to my Gmail address as I don't check
it regularly.
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index