*! doub2flt version 1.0.0 F Wolfe 9/2/1999
program define doub2flt
	version 6.0
	syntax [varlist] [, Mindiff(real .001)]
	tokenize `varlist'
	di
	di "Conversion of type double to type float"
	di
	tempvar diff diffmax
	qui gen `diff' = .
	local nall 0
	local nconv 0

	while "`1'" != "" {
		local type: type `1'
		if "`type'" == "double" {
			local nall = `nall' + 1
			qui replace `diff' = `1' - float(`1')
			qui replace `diff' = abs(`diff')
			qui egen `diffmax' = max(`diff')
			if `diffmax' < `mindiff' {
				local nconv `nconv' + 1
				recast2 float `1', force
				drop `diffmax'
				format `1' %9.0g
			}
		}
	   mac shift
	}
	di `nconv' " of " `nall' " double variable(s) converted to float"
end