**YVO**
capture program drop yvo
program define yvo, rclass
version 9.0
syntax [anything] [fweight pweight iweight] [if] [, cluster(varname) SIGonly SLEVel(real .05) GREATer(namelist) USEREDuction LAST]
local nument: word count `anything'
local namelist `anything'
if `nument'>2{
capture unab namelist: `anything'
}
unab vlist: _all
marksample touse
local test "yvo"

if "`greater'" ~= "" {
	if "`greater'" ~= "col1" & "`greater'"~= "col2" {
		di as err `"Error: "`greater'" Not a Valid Option of Greater"'
		di as err "Greater Option Not Applied"
		local greater
	}
}

if "`last'"=="last" & "`r(colsig)'"=="" & "`r(comm)'"=="" {
	di as err `"Error: No "Last" Configuration Set Present"'
	di as err "Using Full Configuration Set"
	local last
}

if "`usereduction'"=="usereduction" & "`r(reducsols)'"=="" {
	di as err "Error: No Reduction Previously Performed"
	di as err "Can Not Use Reduced Solutions"
	capture keep `vlist'
	exit 119
}

if "`namelist'" ~= "" {
	local v `namelist'
	local y: word 1 of `v'
	local sets: list v - y
	  local nonvar: list v - vlist
        foreach con of local nonvar {
		cnfgen `con'
	  }
          unab sets: `sets'
}

foreach var of local sets {
	qui su `var'
	if `r(max)' > 1 | `r(min)'<0 {
		di as err "Error: `var' Not Fuzzified"
		capture keep `vlist'
		exit 119
	}
}

if "`namelist'" == "" {
	local start = r(start)
	local set "`r(sets)'"
	if "`usereduction'"=="usereduction" {
		local start `r(reducsols)'
		local set `r(reducsols)'
		}
	local commsets `r(comm)'
	if "`last'" == "last"{
		if "`commsets'"=="" {
	 		local set `r(colsig)'
			}
			else {
	 		local set `r(comm)'
			}
	}
	local y = r(y)
	capture myboolean `start'
		if _rc>0{
			local nonvar `set'
        		foreach con of local nonvar {
			cnfgen `con'
			}
		}
	unab sets: `set'
		mark nomis
		capture markout nomis `start'
		qui foreach var of local sets {
		capture replace `var'=. if nomis==0
		}
	qui drop nomis
}

qui foreach var of local sets {
	tempvar bstf`var'
	capture gen `bstf`var'' = 0
	capture replace `bstf`var'' = 1 if `var'>.5 & `var'~=. & `touse'
	su `var'
	if `r(sum)' == 0 {
		local toex `toex' `var'
	}

}

local numexl: word count `toex'
	if `numexl'>0 {
		di
		di in green "Note: `toex' Have No Information and Excluded from Test"
		local sets: list sets - toex
	}

di
di in white "{ul:Y-CONSISTENCY vs All Other Y-CONSISTENCY}"
di as text %-6s "Set", %9s "YCons", %11s "OthYCons", %5s "F", %9s "P", %15s "NumBestFit"
qui foreach var of local sets {
        tempvar o`var'
	  local others : list sets - var
        egen `o`var'' = rowmax(`others')
	  }

foreach var of local sets {
        tempvar num`var' numo`var'
	  qui gen `num`var'' = min(`y',`var')
        qui gen `numo`var'' = min(`y', `o`var'')
	  qui capture recode `bstf`var'' (0=.)
	  qui tab `bstf`var''
	  local bf = r(N)
        qui ratio (`num`var'' `var')(`numo`var'' `o`var'') if `touse' [`weight'`exp'] , cluster(`cluster')
        qui test _b[_ratio_1] = _b[_ratio_2]
		if "`sigonly'" == "sigonly" {
	  		local p = r(p)
	  		if `p' < `slevel' {
        			if "`greater'"== "col1" {
				if _b[_ratio_1]> _b[_ratio_2] {
			  		di as res %-6s "`var'", %9.3f _b[_ratio_1], %9.3f _b[_ratio_2], %9.2f r(F), %9.3f r(p), %9.0f `bf'
			    		local `test'colsig "``test'colsig' `var'"
					}
			    		}
		  	if "`greater'" == "col2" {
				if _b[_ratio_1] < _b[_ratio_2] {
			  		di as res %-6s "`var'", %9.3f _b[_ratio_1], %9.3f _b[_ratio_2], %9.2f r(F), %9.3f r(p), %9.0f `bf'
			    		local `test'colsig "``test'colsig' `var'"
					}
                    		}
                 if "`greater'" == "" {
				di as res %-6s "`var'", %9.3f _b[_ratio_1], %9.3f _b[_ratio_2], %9.2f r(F), %9.3f r(p), %9.0f `bf'
				local `test'colsig "``test'colsig' `var'"
				}
				}
				}
 	else {
		  if "`greater'"== "col1" {
			if _b[_ratio_1]> _b[_ratio_2] {
			  di as res %-6s "`var'", %9.3f _b[_ratio_1], %9.3f _b[_ratio_2], %9.2f r(F), %9.3f r(p), %9.0f `bf'
			    local `test'colsig "``test'colsig' `var'"
			    }
			    }
		  if "`greater'" == "col2" {
			if _b[_ratio_1] < _b[_ratio_2] {
			  di as res %-6s "`var'", %9.3f _b[_ratio_1], %9.3f _b[_ratio_2], %9.2f r(F), %9.3f r(p), %9.0f `bf'
			    local `test'colsig "``test'colsig' `var'"
			    }
			    }
		     if "`greater'" == "" {
			  di as res %-6s "`var'", %9.3f _b[_ratio_1], %9.3f _b[_ratio_2], %9.2f r(F), %9.3f r(p), %9.0f `bf'
		 		local `test'colsig "``test'colsig' `var'"
				}
			      }
	  	  }
return local colsig ``test'colsig'
return local start `start'
return local sets `sets'
return local y `y'
capture keep `vlist'
end