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: Generate a new variable from a string variable containing specific words
From
<redacted>
To
[email protected]
Subject
Re: st: Generate a new variable from a string variable containing specific words
Date
Tue, 13 Nov 2012 12:53:51 +0000
Dear Rich,
It works perfectly. Thanks very much Rich.
best wishes,
<redacted>
On Tue, Nov 13, 2012 at 12:46 PM, Richard Goldstein
<[email protected]> wrote:
> use the inrange function:
>
> gen byte newvar=inrange(icd,"I60","I69")
>
> rich
>
> On 11/13/12 7:40 AM, <redacted> wrote:
>> Hi all,
>>
>> I assume my question is not difficult, but it seems I can not find my
>> way around it. Let us say, I have a string variable named 'icd' and
>> can be inputted as
>>
>> input str8 icd
>> "I60.2"
>> "B25.3"
>> "C34.3"
>> "I65.4"
>> "I68.1"
>> end
>>
>> I would like to generate a new variable that shows as 1 whenever
>> variable 'icd' contain words from I60 to I69, and 0 whenever variable
>> 'icd' does not have that. So for my example, i will have a new
>> variable showing 1 for the 1st, 4th and 5th observation and 0 for
>> others.
>>
>> How can I do that. Really appreciate if someone can help.
>>
>> Regards,
>>
>> <redacted>
>> <redacted>
>> <redacted>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/