Stata 15 help for icd9p

[D] icd9p -- ICD-9-CM procedure codes


Verify that variable contains defined codes

icd9p check varname [if] [in] [, any list generate(newvar)]

Clean variable and verify format of codes

icd9p clean varname [if] [in] [, dots pad]

Generate new variable from existing variable

icd9p generate newvar = varname [if] [in], category

icd9p generate newvar = varname [if] [in], description [long end]

icd9p generate newvar = varname [if] [in], range(codelist)

Display code descriptions

icd9p lookup codelist

Search for codes from descriptions

icd9p search ["]text["] [["]text["] ...] [, or]

Display ICD-9 code source

icd9p query

codelist is

icd9code (the particular code) icd9code* (all codes starting with) icd9code/icd9code (the code range)

or any combination of the above, such as 50.21 37.7* 88.71/88.79. icd9codes must be typed with leading 0s. For example, type 01; typing 1 will result in an error.


Data > ICD codes > ICD-9


icd9p is a suite of commands for working with ICD-9-CM procedure codes from the 16th version (effective October 1998) to the 32nd version. To see the current version of the ICD-9-CM procedure codes and any changes that have been applied, type icd9p query.

icd9p check, icd9p clean, and icd9p generate are data management commands. icd9p check verifies that a variable contains defined ICD-9-CM procedure codes and provides a summary of any problems encountered. icd9p clean standardizes the format of the codes. icd9p generate can create a binary indicator variable for whether the code is in a specified set of codes, a variable containing a corresponding higher-level code, or a variable containing the description of the code.

icd9p lookup and icd9p search are interactive utilities. icd9p lookup displays descriptions of the codes specified on the command line. icd9p search looks for relevant ICD-9-CM procedure codes from key words given on the command line.


Options are presented under the following headings:

Options for icd9p check Options for icd9p clean Options for icd9p generate Options for icd9p search

Options for icd9p check

any tells icd9p check to verify that the codes fit the format of ICD-9-CM procedure codes but not to check whether the codes are defined.

list specifies that icd9p check list the observation number, the invalid or undefined ICD-9-CM procedure code, and the reason the code is invalid or whether it is an undefined code.

generate(newvar) specifies that icd9p check create a new variable containing, for each observation, 0 if the observation contains a defined code or is missing. Otherwise, it contains a number from 1 to 10. The positive numbers indicate the kind of problem and correspond to the listing produced by icd9p check.

Options for icd9p clean

dots specifies that the period be included in the final format. If dots is not specified, then all periods are removed.

pad specifies that icd9p clean pad the codes with spaces, front and back, to make the (implied) dots align vertically in listings. Specifying pad makes the resulting codes look better when used with most other Stata commands.

Options for icd9p generate

category, description, and range(codelist) specify the contents of the new variable that icd9p generate is to create. You do not need to icd9p clean varname before using icd9p generate; it will accept any supported format or combination of formats.

category creates a new variable that contains ICD-9-CM procedure category codes. The resulting variable may be used with the other icd9p subcommands. For procedure codes, the category code is the first two characters.

description creates newvar containing descriptions of the ICD-9-CM procedure codes.

long is for use with description. It specifies that the code be prepended to the text describing the code.

end modifies long (specifying end implies long) and places the code at the end of the string.

range(codelist) creates a new indicator variable equal to 1 when the ICD-9-CM procedure code is in the range specified, equal to 0 when the ICD-9-CM procedure code is not in the range, and equal to missing when varname is missing.

Option for icd9p search

or specifies that ICD-9-CM procedure codes be searched for descriptions that contain any word specified with icd9p search. The default is to list only descriptions that contain all the words specified.


View log of changes made to the list of ICD-9 codes since icd9p was implemented in Stata . icd9p query

Display a description of code 526.4 . icd9p lookup 526.4

Look up a range of codes . icd9p lookup 526/527

Search for codes containing the words jaw and disease . icd9p search jaw disease

Setup . webuse nhds2010

Clean pr1 procedure code variable and add periods . icd9p clean pr1, dots

Check that pr1 contains valid procedure codes if pr1 is not missing . icd9p check pr1 if !missing(pr1)

Create variable dp1 containing descriptions of codes in pr1 . icd9p generate dp1 = pr1, description

Stored results

icd9p check stores the following in r():

Scalars r(e#) number of errors of type # r(esum) total number of errors

icd9p clean stores the following in r():

Scalars r(N) number of changes

icd9p lookup stores the following in r():

Scalars r(N) number of codes found

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