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


First Citizens Bank
Bank of America
World BaNk


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

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