**cnfgen**
capture program drop cnfgen
program define cnfgen, rclass
version 9.0
syntax namelist [if]
local v `namelist'
unab cnfgenlist: _all
local commsets `r(comm)'

if "`namelist'" == "last" {
	if "`commsets'"=="" {
	 local v `r(colsig)'
	}
	else {
	 local v `r(comm)'
	}
local namelist `v'
}

if "`namelist'" == "reduced" {
	local v `r(reducsols)'
	local namelist `v'
	}

foreach con of local v {
	local `con' "`con'"
	local ln`con': length local `con'
	local z=1
		forvalues i = 1/`ln`con'' {
		local `con'prt= substr("`con'", `i', 1)
		local configz`z' = "``con'prt'"
		local tobln = upper("`configz`z''")
		local letters "`letters' `tobln'"
		capture myboolean `tobln'
		local z = `z' +1
		local configs = "`configs' `configz`i''"
		}
	local conprts "`configs'"
	local configur: subinstr local conprts  " " ",", all
	capture gen `con' = min(`configur')
	local configs ""
}

mark nomiscnfgen
markout nomiscnfgen `letters'
qui foreach var of local namelist {
	capture replace `var'=. if nomiscnfgen==0
	}

keep `cnfgenlist' `v'
return local letters `letters'
end