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: RE: RE: AW: Search for string values in dataset??


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: RE: AW: Search for string values in dataset??
Date   Mon, 21 Feb 2011 18:33:27 +0000

Note that there is no need to clone the variable. You just ask Stata to tell you what the result would be if you did. 

... if index(lower(var1), "gmbh")

... if strpos(lower(var1), "gmbh") 

Nick 
n.j.cox@durham.ac.uk 

Eric Booth

One way to match insensitive to case would be to create a lowercase (and (optionally) temporary) version of the string variable and match on that, so:

*********************!
clear
inp str10(var1)
"GmbH7UuIZ"
"GMbH7UuIZ"
"gmbh7Uuiz"
end

tempvar var1_lower 
g `var1_lower' = lower(var1)
g str10 five = var1 if index(`var1_lower', "gmbh") 

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