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

From |
Keith Dear <[email protected]> |

To |
[email protected] |

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

Date |
Sun, 27 Apr 2008 19:06:19 +1000 |

Katrina,

Your way would work if you put quotes around each code, e.g. |`v'=="Y90.1"| . But -inlist- is neater:

foreach v of varlist varname1-varname44 {

replace alcohol=1 if inlist(`v',"Y90","Y90.1","Y90.2",...,"Y91.9")

}

However, I see there is a function -regexm- (regular expression match), which I think you could use something like this (I haven't tried):

replace alcohol=1 if regexm(`v',"Y9[01]\..")

See http://www.stata.com/support/faqs/data/regex.html for the expression operators.

kd (also Australia)

At 06:03 PM 27/04/2008, you wrote:

Dear Stata group users, I have a new data set that I am having difficulty analysing. 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* Or something like that. Any advice greatly appreciated. Katrina, Australia * * 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/

Dr Keith B.G. Dear Senior Fellow in Biostatistics National Centre for Epidemiology and Population Health Australian National University Canberra, ACT 0200, Australia Tel: 02 612 54865, Fax: 02 612 50740 http://nceph.anu.edu.au/Staff_Students/staff_pages/dear.php CRICOS provider #00120C http://canberragliding.org/ * * 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/

**References**:**st: Question re analysing icd10 code data***From:*Katrina Roper <[email protected]>

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

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