*! version 1.0.0  18Oct2016
program define mypoisson6_p
    version 14.2

    syntax newvarname [if] [in] , [ xb n ]

    marksample touse, novarlist

    local nopts : word count `xb' `n'
    if `nopts' >1 {
        display "{err}only one statistic may be specified"
        exit 498
    }

    if `nopts' == 0 {
        local n n
        display "expected counts"
    }

    if "`xb'" != "" {
        _predict `typlist' `varlist' if `touse' , xb
    }
    else {
        tempvar xbv
        quietly _predict double `xbv' if `touse' , xb
        generate `typlist' `varlist' = exp(`xbv') if `touse'
    }
end