*! version 3.1.0  NJC 24 Nov 1997 supports in
* version 3.0.1  11/06/92
program define blogit2
	version 3.0
	local options "Level(integer $S_level) or"
	if "`*'"=="" | substr("`1'",1,1)=="," {
		if "$S_E_cmd"!="blogit2" { error 301 }
		parse "`*'"
		logit, level(`level') `or'
		exit
	}
	local varlist "req ex min(2)"
	local if "opt"
	local in "opt"
	local options "`options' LOg *"
	parse "`*'"
	if "`log'" == "" { local log "nolog" }
	parse "`varlist'", parse(" ")
	confirm new var _outcome
	if `level'<10 | `level'>99 { local level 95 }
	local k = _N
	local k1 = _N + 1
	tempvar pop touse
        mark `touse' `if' `in'
	quietly expand =2, clear
	capture {
		gen byte _outcome=0 in 1/`k'
		replace _outcome=1 in `k1'/l
		gen `pop'=`2'-`1' in 1/`k'
		replace `pop'=`1' in `k1'/l
		mac shift
		mac shift
		noisily logit _outcome `*' [freq=`pop'] if `touse', /*
			*/ level(`level') `or' `options' `log'
		mac def S_E_nobs=_result(1)
		mac def S_E_ll=_result(2)
		mac def S_E_mdf=_result(3)
		mac def S_E_cmd "blogit2"
	}
	local rc = _rc
	quietly keep in 1/`k'
	capture drop _outcome
	error `rc'
end