[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Wildcard for string variables

From   "John Wagai" <>
To   <>
Subject   RE: st: Wildcard for string variables
Date   Thu, 17 Jul 2008 16:11:17 +0300


To get to your final answer use the regex command:

gen seq = regexm(newvar, "Tim")

NB use the newvar generated by Rich below


-----Original Message-----
[] On Behalf Of Richard
Sent: 17 July 2008 16:04
Subject: Re: st: Wildcard for string variables

Sorry about the typo:

gen byte newvar=substr(sequence,1,4)=="Tim "

Richard Goldstein wrote:
> I don't see any need for a wildcard; how about
> gen byte newvar=substr(sequence,1,4)=="Tim"
> Rich
> Hugh Colaco wrote:
>> Hi Statalisters,
>> I am not sure how the string wildcard works. For example, I have a
>> string variable called "sequence" that has the following
>> observations:-
>> 1. "Tim and Tom and Jane"
>> 2. "Tim and Jane and Tom"
>> 3. "Tom and Jane and Harry"
>> 4. "Jane and Jill"
>> I want to generate a new variable that equals one if Tim is the first
>> name mentioned, and zero otherwise.
>> Thanks in advance,
> *
> *   For searches and help try:
> *
> *
> *
*   For searches and help try:

"This e-mail (including any attachment to it) contains information
which is confidential. It is intended only for the use of the named
recipient. If you have received this e-mail in error, please let us know
by replying to the sender, and immediately delete it from your system.
Please note, that in these circumstances, the use, disclosure,
distribution or copying of this information is strictly prohibited. We
apologize for any inconvenience that may have been caused to you.
KEMRI-Wellcome Trust cannot accept any responsibility for the accuracy
or completeness of this message as it has been transmitted over a public
network. The Unit reserves the right to monitor all incoming and
outgoing email traffic. Although the Unit has taken reasonable
precautions to ensure no viruses are present in emails, the Unit cannot
accept responsibility for any loss or damage arising from the use of the
email or attachments. Any views expressed in this message are those of
the individual sender, except where the sender specifically states them
to be the views of KEMRI- Wellcome Trust Research".

*   For searches and help try:

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