Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: recode non-numerical values


From   Phil Clayton <philclayton@internode.on.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: recode non-numerical values
Date   Mon, 2 May 2011 23:02:16 -0400

This will make missing values of DrugID have a value of drug==0. This may be what you want but generally it would be better to keep them as missing, so I would suggest modifying to:

gen byte drug = (DrugID=="d06662") if !missing(DrugID)

Phil

On 02/05/2011, at 10:51 PM, Keith Dear wrote:

> gen byte drug = (DrugID=="d06662")
> 
> On 3 May 2011 12:16, Jet <lsj555@gmail.com> wrote:
>> Hi, everyone,
>> 
>>      I have a question regarding matching of nonnumerical values.
>> Suppose the original data looks like this:
>> 
>>   ID     Drug ID
>>    1      d06662
>>    2      d06665
>>    3      d04878
>>    4      d05048
>> 
>>    Now  suppose d06662 is a drug for hypertension, which I want to
>> code into "1", and all else into "0". I tried to destring the
>> variable, but it does not allow me doing so since it contains
>> characters. Any suggestion to handle this situation?
>> 
>>       thanks
>>        Jeff
>> *
>> *   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/
>> 
> 
> 
> 
> -- 
> Dr Keith Dear
> National Centre for Epidemiology and Population Health
> ANU College of Medicine, Biology and Environment
> Australian National University
> Canberra, ACT 0200 Australia
> Phone +61 (02) 6273 2208
> 
> *
> *   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index