Instructions: Step-by-Step Guide to Accessing NHAMCS-ED Public Use Data Files and Programs to Select Injury Records and Calculate Rates


STATA Programs for Identifying Injury Records

On this Page

The following “Do” files run STATA statements that will identify which NHAMCS emergency department records were for injuries based on the NCHS Injury Team’s definition of injury (See Recommended definition of initial injury visits to emergency departments for use with the NHAMCS-ED data, available on the injury website, for more information.) The injury indicator field is called INJSPB. In 2005, the way in which this field was derived changed due to a change in fields on the record. The first do-file is for using data from 2005 and the second do-file is for data from 2002-2004.

*DO-FILE FOR USING DATA FROM 2005

*Replace c:nhamcsed with the directory containing your dataset
Cd “c:nhamcsed”

*Replace ed with the name of your dataset
use “ed.dta”, clear
*Create variables to use in deriving the injury indicator
gen causedet=strofreal(cause13d)
gen diag14d=substr(diag1,1,4)
gen diag15d=diag1

*Determine if record has an external cause of injury
gen EXTINJ=0

replace EXTINJ=1 if (causedet >= “800” & causedet <= “869”)
replace EXTINJ=1 if (causedet >= “880” & causedet <= “929”)
replace EXTINJ=1 if (causedet >= “950” & causedet <= “999”)
replace EXTINJ=2 if (causedet >= “870” & causedet <= “879”)
replace EXTINJ=2 if (causedet >= “930” & causedet <= “949”)

*Determine if the first listed diagnosis on the record is for injury
gen NEWINJ=0

replace NEWINJ=1 if (diag14d >= “8000” & diag14d <= “9092”)
replace NEWINJ=1 if (diag14d == “9094” )
replace NEWINJ=1 if (diag14d >= “9099” & diag14d <= “9949”)
replace NEWINJ=1 if (diag15d >= “99550” & diag15d <= “99559”)
replace NEWINJ=1 if (diag15d >= “99580” & diag15d <= “99585”)
replace NEWINJ=2 if (diag13d < “800” | diag13d > “999”)

*Determine if the record should be considered an injury record
gen INJSPB=0

replace INJSPB=1 if (initvis==1 & (NEWINJ==1 & EXTINJ==1))
replace INJSPB=1 if (initvis ==1 & (NEWINJ==1 & EXTINJ==0))
replace INJSPB=1 if (initvis ==1 & (NEWINJ==2 & EXTINJ==1))

*Run frequency of injuries weighting data with patwt
tab INJSPB [weight=patwt]

*DO-FILE FOR USING DATA FROM 2002-2004

*Replace c:nhamcsed with the directory containing your dataset
Cd “c:nhamcsed”

*Replace ed with the name of your dataset
use “ed.dta”, clear

*Create variables to use in deriving the injury indicator
gen causedet=strofreal(cause13d)
gen diag14d=substr(diag1,1,4)
gen diag15d=diag1

*Determine if record has an external cause of injury
gen EXTINJ=0

replace EXTINJ=1 if (causedet >= “800” & causedet <= “869”)
replace EXTINJ=1 if (causedet >= “880” & causedet <= “929”)
replace EXTINJ=1 if (causedet >= “950” & causedet <= “999”)
replace EXTINJ=2 if (causedet >= “870” & causedet <= “879”)
replace EXTINJ=2 if (causedet >= “930” & causedet <= “949”)

*Determine if the first listed diagnosis on the record is for injury
gen NEWINJ=0

replace NEWINJ=1 if (diag14d >= “8000” & diag14d <= “9092”)
replace NEWINJ=1 if (diag14d == “9094” )
replace NEWINJ=1 if (diag14d >= “9099” & diag14d <= “9949”)
replace NEWINJ=1 if (diag15d >= “99550” & diag15d <= “99559”)
replace NEWINJ=1 if (diag15d >= “99580” & diag15d <= “99585”)
replace NEWINJ=2 if (diag13d < “800” | diag13d > “999”)

*Determine if the record should be considered an injury record
gen INJSPB=0

replace INJSPB=1 if (episode==1 & (NEWINJ==1 & EXTINJ==1))
replace INJSPB=1 if (episode==1 & (NEWINJ==1 & EXTINJ==0))
replace INJSPB=1 if (episode==1 & (NEWINJ==2 & EXTINJ==1))

*Run frequency of injuries weighting data with patwt
tab INJSPB [weight=patwt]

Page last reviewed: November 6, 2015