program define cndnmb3
	*! 1.0 M Blasnik 7/29/1998 based on J Harkness -cndnmbr-
	version 5.0
	local varlist "req ex"
	local if "opt"
	local in "opt"
	parse "`*'"
	tempvar touse
	mark `touse' `if' `in'
	markout `touse' `varlist'
	tempname x XTX temp cvalues
	parse "`varlist'", parse(" ")
	quietly {
	local k=1
	while "``k''" !="" {
		mat accum `x'=``k'' if `touse', nocons
		tempvar v`k'
		gen double `v`k''=``k''/sqrt(`x'[1,1]) if `touse'
		local tvars "`tvars' `v`k''"
		local k=`k'+1
	}
	matrix accum `XTX'= `tvars' , nocons
	matrix symeigen `temp' `cvalues' = `XTX'
	local cndnmbr=sqrt(`cvalues'[1,1]/`cvalues'[1,`k'-1])
	}
	display "condition number=" %9.3g `cndnmbr'
	global S_1 = `cndnmbr'
end