Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: filter by value labels


From   daniel klein <[email protected]>
To   [email protected]
Subject   Re: st: filter by value labels
Date   Thu, 31 Mar 2011 20:33:00 +0200

Here is a sketch, using -decode- temporarily. Might be a starting point.

cap prog drop foo
prog foo
	version 11.1
	tempname _strvar _i
	qui dec `: word 1 of `0'' ,g(`_strvar')
	qui g byte `_i' = strmatch(`_strvar', `"`: word 2 of `0''"')
	drop `_strvar'
	loc vars `vars' `: word 1 of `0''
	forval j = 3(2)`: word count `0'' {
		loc k = `j' + 1
		qui dec `: word `j' of `0'' ,g(`_strvar')
		qui replace `_i' ///
			= strmatch(`_strvar' ,`"`: word `k' of `0''"') ///
			if `_i'
		drop `_strvar'
		loc vars `vars' `: word `j' of `0''
	}
	l `vars' if `_i'
end

. sysuse nlsw88, clear
. foo race other married marr* collgrad col* occ Sal*
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index