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   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: filter by value labels
Date   Thu, 31 Mar 2011 16:01:15 -0400

Daniel Klein <[email protected]>:
I think the poster wanted to avoid -decode- because the datasets
involved are very large, but there is no need to fire up -decode- or
make any tempvars, I think.

prog drop _all
prog labmatch
version 11.1
loc c 1
forval j = 1(2)`: word count `0'' {
loc v: word `j' of `0'
loc vs `vs' `v'
loc m: word `=`j'+1' of `0'
mata:v=J(1,1,.)
mata:t=J(1,1,.)
mata:st_vlload("`:val lab `v''",v,t)
mata:st_local("s",invtokens(strofreal(select(v,strmatch(t,"`m'"):>0)')))
tokenize `s'
while `"`1'"'!="" {
 loc c `c'&`v'==`1'
 mac sh
 }
}
l `vs' if `c'
end
sysuse nlsw88, clear
labmatch race other married marr* collgrad col* occ Sal*


On Thu, Mar 31, 2011 at 2:45 PM, daniel klein
<[email protected]> wrote:
> ...make "tempname" in line 4 "tempvar"
>
> By the way, if it is not clear from the example, the "syntax" is:
>
> foo varname "value label to be matched" varname "value label to be matched" ...
*
*   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