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]

st: RE: RE: AW: Search for string values in dataset??


From   "Liao, Junlin" <junlin-liao@uiowa.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: AW: Search for string values in dataset??
Date   Mon, 21 Feb 2011 16:35:26 +0000

Very clever. We can simply apply either the -lower- or -upper- function to both the argument in -strmatch-, -regexm-, or -index-(strops) functions. It will render those functions case insensitive. Thanks,

Junlin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Eric Booth
Sent: Monday, February 21, 2011 10:18 AM
To: <statalist@hsphsun2.harvard.edu>
Subject: Re: st: RE: RE: AW: Search for string values in dataset??

<>

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

//1.  from Markus and Junlin//
g one = 1 if strmatch(var1, "*GmbH*")
g byte two = regexm(var1, "GmbH")
list var1 if regexm(var1, "GmbH")

//2.  Another option:  index //
g str10 three = var1 if index(var1, "GmbH") g str10 four = var1 if index(var1, "gmbh") list var1 if index(var1, "GmbH")

//3.  case insensitive - lower case matches // tempvar var1_lower g `var1_lower' = lower(var1) g str10 five = var1 if index(`var1_lower', "gmbh")
/* could evaluate to 1 if matched (instead of var1 contents) */ l *********************!

- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu
Office: +979.845.6754

On Feb 21, 2011, at 9:52 AM, Liao, Junlin wrote:

> Continue on this topic, anyone has a good way to make those two
> commands case insensitive? Thanks,
>
> Junlin
>
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Liao,
> Junlin
> Sent: Monday, February 21, 2011 9:40 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: AW: Search for string values in dataset??
>
> Miyu,
>
> Another command is -regexm-
>
> gen byte GmbH_Match = regexm(variable, "GmbH")
>
> If you simply want to list the entries:
>
> list variable if regexm(variable, "GmbH")
>
> Junlin
>
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Wiemann,
> Markus
> Sent: Monday, February 21, 2011 9:17 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: AW: Search for string values in dataset??
>
> Hi Miyu,
>
> try the -strmatch- command.
> For example:
> gen GmbH = 1 if strmatch(variablename, "*GmbH*")
>
>
> Best
> Markus
>
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von miyu Lee
> Gesendet: Montag, 21. Februar 2011 16:12
> An: statalist@hsphsun2.harvard.edu
> Betreff: st: Search for string values in dataset??
>
> Is there ANY way to search for specific string values in a dataset with string variables? For example: I am searching for all entries showing the part "GmbH" in a vector with firm names. I have a bad feeling about this!
>
> Best
> Miyu
> *
> *   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/
>
>
> ________________________________


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


________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________

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