Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: search the dataset for a string value


From   Dan Blanchette <[email protected]>
To   [email protected]
Subject   Re: st: search the dataset for a string value
Date   Mon, 23 Feb 2004 09:53:30 -0500 (EST)

The string function -index- searches a string or a string variable
and returns the position it found the string being searched for or
zero if not found.

. help strfun

. list MyStrVar if index(MyStrVar,"bank")

Or you could search for "bank" in any combination of upper or
lower case by using the -lower- function:

. list MyStrVar if index(lower(MyStrVar),"bank")

will list

MyStrVar

First Citizens Bank
Bank of America
bank
World BaNk

dan


>From 	  [email protected]
>To 	  [email protected]
>Subject 	  st: search the dataset for a string value
>Date 	  Mon, 23 Feb 2004 14:20:51 +0000
>
>Dear Statalisters,
>
>Probably this question came up many times, but I can not -findit-.
>How do I search for a "string value" in one vector of string observations?
>For example search for "bank" in the "company name" variable, so that I will get
>all entries that contain the value "bank".
>
>many thanks in advance
>Dimitris Christodoulou




*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index