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: How to check whether a string variable contains some characters
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: How to check whether a string variable contains some characters
Date
Sat, 26 May 2012 00:25:34 +0100
There is an -if- command and an -if- qualifier: see -help ifcmd- and
-help if-. Without seeing your code we can't tell whether your code is
incorrect, your terminology is incorrect, or both. This example
indicates how to use the -strpos()- function to select values of
-make- that contain the characters "Ford".
. sysuse auto
(1978 Automobile Data)
. l make if strpos(make, "Ford")
+--------------+
| make |
|--------------|
24. | Ford Fiesta |
25. | Ford Mustang |
+--------------+
This is an example of using the -if- qualifier.
Nick
On Fri, May 25, 2012 at 10:38 PM, Bersant Hobdari <[email protected]> wrote:
> I am working with a firm level data set, which contains, among other
> things, data on firm names and place of incorporation. This latter
> variable has a lot of missing values, which I would like to fill in to
> the extent possible by using the firm name variable. More
> specifically, if the firm name contains certain information, let say
> the extension GHMB, I would infer that the firm is incorporated in
> Germany. I am trying to use the "if" command to perform this operation
> but I keep getting an error message. Can this command be applied in
> this occasion? If not, is there any other command that can check
> whether a string variable contains certain characters?
>
*
* 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/