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   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: filter by value labels
Date   Thu, 31 Mar 2011 17:59:56 +0100

Nick 
[email protected] 


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: 31 March 2011 17:45
To: '[email protected]'
Subject: RE: st: filter by value labels

Thanks; your situation is now clearer to me. I think you need to -decode- but I understand that you are reluctant to do that. 

With string values, your conditions could be rewritten

... if strmatch(firstname, "Joe") & strmatch(firstname, "Doe") & strmatch(town, "Frankfurt")

... if strpos(firstname, "Joe") & strpos(firstname, "Doe") & strpos(town, "Frankfurt") 

as 

if strmatch() == 1 

is equivalent to 

if strmatch()

and 

if strpos() > 0  

is equivalent to 

if strpos() 

But those are minor details. 

Nick 
[email protected] 

On Behalf Of [email protected]

Thanks Nick,

this is the idea I was looking for but unfortunately it doesn’t fit to my example.


The use of  

"value_label_content":value_label_name 

is restricted to single values and their corresponding value labels where the latter must be known.

In my case value labels are unknown and I want to check and filter those containing defined substrings. 

In correction to my first post the command with non-encoded vars would be like that:
tab unitid if strmatch(firstname ,"*Joe*") == 1 & strmatch(firstname ,"Doe*") == 1 & strmatch(town ,"*Frankfurt*") == 1

(So "Joe" could have other names too, Frankfurt could be named "Stadt Frankfurt" or "Frankfurt am Main"...)
(The usual hassle with address data...)

There is none but if there was e.g. some function "vallabel" that would substitute variable values with their corresponding value labels (e.g. for comparison in -strmatch - ) I would encode more often and some of my datasets could be much smaller. 


*
*   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/

*
*   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