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

📄 expandcl.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 1.0.1  07apr2005
program expandcl, sortpreserve
	version 9
	gettoken equal : 0, parse("=")
	if "`equal'" != "=" {
		local 0 `"= `0'"'
	}
	syntax =exp [if] [in],		///
		GENerate(name)		///
		CLuster(varlist)

	confirm new variable `generate'

	marksample touse, novarlist

	tempvar vexp oid cid eid

quietly {

	gen `vexp' `exp'

	// generate cluster id variable that contains the contiguous integers
	// 1, ..., `ncl'; where `ncl' is the number of clusters

	sort `touse' `cluster', stable
	capture by `touse' `cluster': ///
		assert int(`vexp') == int(`vexp'[1]) if `touse'
	if c(rc) {
		di as err "expression is not constant within clusters"
		exit 198
	}

	by `touse' `cluster': gen `cid' = _n==1
	replace `cid' = sum(`cid')
	local ncl = `cid'[_N]
	gen `oid' = _n

	noisily expand `exp'

	// generate the cluster id variable that is unique between the copies
	// of the original clusters

	sort `touse' `cluster' `oid', stable
	by `touse' `cluster' `oid': gen `eid' = (`cid'-1)*`ncl'+_n
	sort `touse' `cluster' `eid', stable
	drop `oid'
	by `touse' `cluster' `eid': gen `oid' = _n==1 if `touse'
	replace `eid' = sum(`oid') if `touse'
	rename `eid' `generate'

} // quietly

end
exit

⌨️ 快捷键说明

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