![Statalist](/includes/images/head_statalist.jpg) |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: destring
Hi List,
I am having a great deal of trouble changing strings to numeric. I have
a variable "drug_1" that is a strg40 with 32 unique values (I did not
create this data set!). Examples are:
"TESTOSTERONE CYP 200MG/ML INJ (IN OIL) "
"TESTOSTERONE ENANTH. 200MG/ML 1ML "
"TESTOSTERONE ENANTHATE 200MG/ML INJ 5ML "
"TESTOSTERONE ENANTHATE 200MG/ML INJ 5ML "
TESTOSTERONE (ANDRODERM) 5MG/24HRS PATCH
Drug dose is the explore variable and the PI wants to look at outcome by
mode of administration and dose, so for the example here I need to have
a drug_1 variable with mode 1=IM and 2=patch and dose 200mg/ml,
200mg/5ml and 5mg/24hr.
I have tried encode, but I do not think I can use that because the
strings also contain numbers(please correct if this is not true). I
tried destring with the following errors:
destring Drug_1, replace
Drug_1 contains non-numeric characters; no replace
. destring Drug_1, replace ignore("testosterone")
Drug_1 contains characters not specified in ignore(); no replace
I could not find anything in FAQ that was similar to this problem. I
would appreciate ANY HELP as I have drug_1 through drug_5 for 384
subjects and can do this the long and painful way, but would prefer not.
Thanks, Peggy
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/