Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: entire contents of a value label


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: entire contents of a value label
Date   Wed, 1 Dec 2004 16:17:54 -0600

At 1:53 PM -0500 12/1/04, Kit Baum wrote:
use http://www.stata-press.com/data/r8/labelbook1.dta,clear
* zap one to make sure that it works with gaps
label define rs015 3 "", modify
label list rs015

forv i=`r(min)'/`r(max)' {
	local labval: label rs015 `i'
	if ("`labval'" ~= "`i'") local rs015lab "`rs015lab' | `labval'"
	}
di "`rs015lab'"

Thanks very much to Nick (C), Kit, and Nick (W) for responding to my question. I hadn't realized that -label list- stores the minimum and maximum of the mapping's domain in r() (had I read the manual more carefully, I would have known this). Assuming that the mapping consists of a contiguous set of integers (e.g., like those generated by -encode-), then Kit's solution is fully efficient for what I'd wanted to do.


-- Phil
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index