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

📄 _labels2names.ado

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 ADO
字号:
*! version 1.0.1  18nov2004
program _labels2names, sclass sortpreserve
	syntax varname(numeric) [if] [in] [,	///
		Missing				///
		noLABel				///
		stub(name)			///
		Indexfrom(integer 1)		///
		noINTegers			///
		Namelist(string)		///
		RENUMber			///
	]

	local cat `varlist'
	if "`stub'" == "" {
		local stub _name_
	}
	if "`missing'" != "" {
		local novarlist novarlist
	}
	marksample touse, `novarlist'
	quietly replace `touse' = . if `touse' != 1
	tempvar x
	sort `cat' `touse', stable
	quietly gen byte `x' = 1 if `cat' != `cat'[_n-1] & `touse' == 1
	sort `x' `cat', stable
	quietly count if `x' == 1
	local n_cat = r(N)

	if "`label'" == "" {
		local label :value label `cat'
		capture label list `label'
		// `label' might be an empty value label name
		if (c(rc)) local label
		if "`label'" != "" {
			tempname strx
			decode `cat' in 1/`n_cat',	///
				gen(`strx') maxlength(`c(namelen)')
			quietly replace `strx' = trim(`strx')
			quietly replace `strx' = string(`cat')	///
				if missing(`cat') | `strx' == ""
		}
	}
	local j `indexfrom'
	forval i = 1/`n_cat' {
		local tag
		local lab
		local val
		if "`strx'" != "" {
			local lab = `strx'[`i']
			capture {
				assert `:word count `lab'' == 1
				confirm name `lab'
			}
			if !c(rc) {
				// found a valid name
				local tag `lab'
			}
			else if "`integers'" == "" {
				// found (non-negative) integer value
				capture confirm integer number `lab'
				if !c(rc) &			///
				( ("`renumber'" != "") |	///
				  (string(`cat'[`i']) == `"`lab'"') ) {
					if (`lab' >= 0) local tag `lab'
				}
			}
		}
		else {
			local val = string(`cat'[`i'])
			if "`integers'" == "" {
				capture confirm integer number `val'
				if !c(rc) {
					// found (non-negative) integer value
					if (`val' >= 0) local tag `val'
				}
			}
		}
		if "`tag'" == "" |	///
		("`tag'" != "" & `:list tag in namelist') {
			local tag `stub'`j++'
			while `:list tag in namelist' {
				local tag `stub'`j++'
			}
		}
		else	local ++j
		local namelist `namelist' `tag'
		local names `names' `tag'
		if `:word count `lab'' > 1 {
			local labels `"`labels' `"`lab'"'"'
		}
		else	local labels `"`labels' `lab'`val'"'
	}

	sreturn clear
	sreturn local n_cat	`n_cat'
	sreturn local names	`names'
	sreturn local namelist	`namelist'
	sreturn local labels	`"`:list retok labels'"'
	sreturn local indexfrom	`j'
end

exit

⌨️ 快捷键说明

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