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

From |
Svend Juul <SJ@SOCI.AU.DK> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: Question re analysing icd10 code data |

Date |
Sun, 27 Apr 2008 11:01:39 +0200 |

Katrina wrote: The dataset contains 44 fields for icd10 (hospital) codes. There are many hundreds of codes, and these can be put in any one of the columns. For example, I am interested in the alcohol codes, of which there are 17. The codes are in string form. The alcohol codes are for example Y90, Y90.0, Y90.1, Y91, Y91.0 etc etc in 17 different forms. What I want to do is find every time any one of the 17 different alcohol codes appears in any one of the 44 columns. I tried this: gen alcohol=. foreach v of varlist varname1 - varname44 { replace alcohol=1 if (`v'==Y90|`v'==Y90.1|`v'==Y90.2| until `v'==Y91.9) } but it didn't work, I suspect maybe because the data is in string form. Basically is there any way of doing a Boolean type search using Stata to answer the question: For any column icd1-icd44 find/count where the variable == Y90* | Y91* ============================================================= With a string variable, you must put the values in quotes: ... `v'=="Y90" A bit against intuition: You can use > and < in relational string expressions, so you can: generate alcohol=0 foreach V of varlist dx1-dx44 { replace alcohol=1 if `V' >= "Y90" & `V' < "Y92" } Another technique: replace alcohol=1 if strpos(`V',"Y90")>0 | strpos(`V',"Y91")>0 The techniques are desribed in S Juul: An Introduction to Stata for Health Researchers (Stata Press), section 5.6. Hope this helps Svend ________________________________________________________ Svend Juul Institut for Folkesundhed, Afdeling for Epidemiologi (Institute of Public Health, Department of Epidemiology) Vennelyst Boulevard 6 DK-8000 Aarhus C, Denmark Phone, work: +45 8942 6090 Phone, home: +45 8693 7796 Fax: +45 8613 1580 E-mail: sj@soci.au.dk _________________________________________________________ * * 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/

- Prev by Date:
**st: Question re analysing icd10 code data** - Next by Date:
**Re: st: Question re analysing icd10 code data** - Previous by thread:
**Re: st: Question re analysing icd10 code data** - Index(es):

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