program sreg,eclass
if "x$release"=="x" {
   di "sreg: Error: Must specify release in global macro"
   exit 323
}
log using $release, text append name($release)
di "mincellsize: $mincellsize"
if "x$mincellsize"=="x" {
   di "Error: Must specify mincellsize in global macro"
   exit 324
}
matrix eb=e(b)
matrix ev=e(V)
local vars : rownames(ev)
scalar last=colsof(eb)
local last=last
forvalues i=1/`last' {       //Round coef and se to 3 significant digits
    tempname b
    scalar `b' = eb[1,`i']
    if `b'!=.&`b'!=0 scalar `b'=sign(`b')*round(abs(`b'),10^(floor(log10(abs(`b')))-3))
    matrix eb[1,`i'] = `b'

    scalar `b' = ev[`i',`i']
    if `b'!=.&`b'!=0 scalar `b'=sign(`b')*round(abs(`b'),10^(floor(log10(abs(`b')))-3))
    matrix ev[`i',`i'] = `b'



    local var : word `i' of `vars'

    quietly {
      tempvar tabvar
      gen `tabvar' = `var'
      tab `tabvar' if e(sample), matcell(M)
    }
    scalar numcats = r(r)
    if numcats==2 {     // Check for rare or universal dummies
       if M[1,1]<$mincellsize | M[2,1]<$mincellsize {
          matrix eb[1,`i'] = 0
          matrix ev[`i',`i'] = 0
       }
    }
}
*Always censor constant.
local _cons=colnumb(eb,"_cons")
matrix eb[1,`_cons'] = 0
matrix ev[`_cons',`_cons'] = 0
* Use Stata for output
_coef_table ,bmatrix(eb) vmatrix(ev)
di "0 values indicate fewer than $mincellsize records" ///
   " (or secondary suppression of the constant)."

ereturn repost b=eb V=ev
log close release
end