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

Re: st: Question re analysing icd10 code data

From   Keith Dear <>
Subject   Re: st: Question re analysing icd10 code data
Date   Sun, 27 Apr 2008 19:06:19 +1000

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 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
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

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.


*   For searches and help try:

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
CRICOS provider #00120C

*   For searches and help try:

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