⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _vce_parserun.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 1.0.13  07apr2005
program _vce_parserun, sortpreserve eclass byable(onecall)
	version 9
	local version : di "version " string(_caller()) ":"
	local bycall = _by()

	// syntax: <caller> [, options ] : <caller's arguments>
	_on_colon_parse `0'
	local 0 `"`s(before)'"'
	local rest `"`s(after)'"'
	syntax name(name=caller id="calling command name") [,	///
		WTYPES(string)					///
		NOJACKknife					///
		NOBOOTstrap					///
		NOOTHERvce					///
		NOTEST						///
		PANELdata					///
		STdata						///
		jkopts(string asis)				///
		bootopts(string asis)				///
		robustok					///
		multivce					///
	]

	if "`wtypes'" == "" {
		local wtypes fw aw pw iw
	}

	local 0 `"`rest'"'
	local rest

	if "`paneldata'" != "" {
		local panelopt "CLuster(varname) I(varname)"
	}
	if "`stdata'" != "" {
		local stopt "CLuster(varname) SHared(varname)"
	}

	local typelist svy jackknife bootstrap
	if "`stdata'" == "" & replay() & ! _by() {
		// replay, but only if this is not a call from an -st- command
		local ecmd `e(cmd)'
		local ecmdname `e(cmdname)'
		if `"`ecmd'"' == "" {
			error 301
		}
		else if `"`ecmd'"' != "`caller'" ///
		 & `"`ecmdname'"' == "`caller'" ///
		 & `:list ecmd in typelist' {
			`ecmd' `0'
			MYRESULT exit
		}
		MYRESULT
		exit
	}
	// remove svy from the list, it is only relevent for replay and not
	// considered a "true" vce_type, for general use
	gettoken svy typelist : typelist

	quietly							///
	syntax [anything(equalok)] [if/] [in] [`wtypes'] [,	///
		VCE(string asis)				///
		VCE1(string asis)				///
		*						///
	]

	// nothing to do, let the caller run through as usual
	if `"`vce'"' == "" {
		MYRESULT
		exit
	}
	if "`robust'" != "" & "`robustok'" == "" {
		di as err "options vce() and robust may not be combined"
		exit 198
	}
	if `:list vce === vce1' {
		local vce1
	}
	if `"`vce1'"' != "" & "`multivce'" == "" {
		di as err "option vce() specified multiple times"
		exit 198
	}
	syntax [anything(equalok)] [if/] [in] [`wtypes'] [,	///
		VCE(string asis)				///
		VCE1(string asis)				///
		Robust						///
		NODOTS						///
		`panelopt'					///
		`stopt'						///
		*						///
	]
	if `"`if'"' != "" {
		local if `"if (`if')"'
	}
	if "`robust'" != "" {
		local options `"`robust' `options'"'
	}
	if "`weight'" != "" {
		local wgt [`weight'`exp']
	}
	if `"`options'"' != "" {
		local opts `"`:list retok options'"'
	}

	gettoken uvcetype vceopts : vce, parse(" ,")

	capture unabVCEtype, `uvcetype'
	// problem with -vce()-
	if c(rc) {
		di as err "invalid vce() option"
		exit c(rc)
	}
	local vcetype `s(vcetype)'

	if `"`vce1'"' != "" & "`multivce'" != "" {
		gettoken uvce1type vc1eopts : vce1, parse(" ,")
		capture unabVCEtype, `uvce1type'
		// problem with -vce()-
		if c(rc) {
			di as err "invalid vce() option"
			exit c(rc)
		}
		local vce1type `s(vcetype)'
		if `:list vce1type in typelist' ///
		 | `:list vcetype  in typelist' {
			di as err ///
"options vce(`vce') and vce(`vce1') cannot be combined"
			exit 198
		}
		MYRESULT
		exit
	}

	if ! `:list vcetype in typelist' {
		if "`vcetype'" == "robust" {
			if `"`vceopts'"' != "" {
				di as err "option vce(`vce') not allowed"
				exit 198
			}
			if `"`anything'"' != "" {
				local zero `"`anything'"'
			}
			if `"`weight'"' != "" {
				local zero `"`anything' [`weight'`exp']"'
			}
			if `"`if'"' != "" {
				local zero `"`zero' `if'"'
			}
			if `"`in'"' != "" {
				local zero `"`zero' `in'"'
			}
			local zero `"`zero', robust"'
			if `"`options'"' != "" {
				local zero `"`zero' `options'"'
			}
			if "`paneldata'" != "" {
				if `"`i'"' != "" {
					local zero `"`zero' i(`i')"'
				}
				if `"`cluster'"' != "" {
					local zero `"`zero' cluster(`cluster')"'
				}
			}
			if "`stdata'" != "" {
				if "`cluster'" != "" {
					local zero `"`zero' cluster(`cluster')"'
				}
				if "`shared'" != "" {
					local zero `"`zero' shared(`shared')"'
				}
			}
			c_local 0 `"`:list retok zero'"'
		}
		else if "`noothervce'" == "noothervce" {
			di as err "option vce(`uvcetype') not allowed"
			exit 198
		}
		MYRESULT
		exit
	}

	if `bycall' {
		di as err ///
		"the by prefix may not be used with vce(`uvcetype') option"
		exit 190
	}

	if `"`:list retok vceopts'"' == "" {
		local vceopts ","
	}
	if "`paneldata'" != "" {
		if `"`i'"' != "" {
			local opts "`opts' i(`i')"
		}
		else {
			quietly xt_iis
			local i `s(ivar)'
		}
		if "`cluster'" != "" {
			local opts `"`opts' cluster(`cluster')"'
			local clopt noecluster
			if `"`vcetype'"' == "bootstrap" {
				tempvar tmpcl
				local idopt group(`i') idcluster(`tmpcl')
			}
		}
		else {
			if `"`vcetype'"' == "jackknife" {
				local clopt cluster(`i')
			}
			if `"`vcetype'"' == "bootstrap" {
				tempvar tmpi
				quietly gen `:type `i'' `tmpi' = `i'
				local clopt cluster(`tmpi')
				local idopt idcluster(`i')
			}
		}
	}
	if "`stdata'" != "" {
		local id : char _dta[st_id]
		if "`cluster'" != "" {
			local opts "`opts' cluster(`cluster')"
			local clopt noecluster
			// note: -cluster()- and -shared()- may not both be
			// specified
			if "`id'" != "" & "`vcetype'" == "bootstrap" {
				tempvar tmpid
				local idopt idcluster(`tmpid') group(`id')
			}
		}
		else if "`shared'" != "" {
			local opts "`opts' shared(`shared')"
			if "`vcetype'" == "jackknife" {
				local clopt cluster(`shared')
			}
			if "`vcetype'" == "bootstrap" {
				tempvar tmpid
				quietly gen `:type `shared'' `tmpid' = `shared'
				local clopt cluster(`tmpid')
				local idopt idcluster(`shared') group(`id')
			}
		}
		else if "`id'" != "" {
			if "`vcetype'" == "jackknife" {
				local clopt cluster(`id')
			}
			if "`vcetype'" == "bootstrap" {
				tempvar tmpid
				confirm var `id'
				quietly gen `:type `id'' `tmpid' = `id'
				local clopt cluster(`tmpid')
				local idopt idcluster(`id')
			}
		}
		if "`caller'" == "stcox" {
			local opts "`opts' altvce(`vcetype')"
		}
	}
	if `"`vcetype'"' == "jackknife" {
		if "`nojackknife'" == "nojackknife" {
			di as err ///
			"option vce(jackknife) not allowed"
			exit 198
		}
		local vceopts `"`vceopts' `notest' `jkopts' `clopt'"'
	}
	if `"`vcetype'"' == "bootstrap" {
		if "`nobootstrap'" == "nobootstrap" {
			di as err ///
			"option vce(bootstrap) not allowed"
			exit 198
		}
		local vceopts `"`vceopts' `notest' `bootopts' `clopt' `idopt'"'
	}
	if `"`:list retok opts'"' != "" {
		local opts `", `opts'"'
	}

	`version' `vcetype' `vceopts' `nodots' :	///
	`caller' `anything' `if' `in' `wgt' `opts'

	// fix e(ivar) for the -xt- commands
	if "`i'" != "" & `"`vcetype'"' == "bootstrap" {
		ereturn local ivar `"`i'"'
	}

	MYRESULT exit
end

program unabVCEtype, sclass
	syntax [, BOOTstrap BStrap JACKknife JACKNife JKnife Robust * ]
	if "`bstrap'" != "" {
		local bootstrap bootstrap
	}
	if "`jknife'" != "" | "`jacknife'" != "" {
		local jackknife jackknife
	}
	local vcetype `"`jackknife' `bootstrap' `robust' `options'"'
	sreturn local vcetype `"`:list retok vcetype'"'
end

// return something to indicate an action was taken (or not), and the calling
// command can just exit (or do its normal thing)

program MYRESULT, sclass
	args exit
	sreturn local exit `"`exit'"'
end

exit

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -