Thanks Rich. And what if I'm looking for "Jane" anywhere inside the
string (i.e. it could be leading, somewhere in the middle, or at the
end, or even multiple times)?
Hugh
On Thu, Jul 17, 2008 at 9:03 AM, Richard Goldstein
<[email protected]> wrote:
> 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:
>> * 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/
>
--
Hugh
*
* 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/