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

st: RE: using the command substr in stata

From   "Matt Spittal" <>
To   <>
Subject   st: RE: using the command substr in stata
Date   Wed, 30 Jul 2008 12:15:04 +1000

Hi Carmen,

I am not familiar with these datasets, but -help icd9- brings up the Stata command -icd9-, which can generate new variables from existing ICD9 codes.  This may be a better way to go than doing the recodes yourself.

-- Matt 

-----Original Message-----
[]On Behalf Of carmen gamarra
Sent: Wednesday, 30 July 2008 9:50 AM
Subject: st: using the command substr in stata

hi, I have a problem for which I am sure STATA has an
easy solution but I couldn’t to find it.  I hope you can help

Here is what I need to do:
I have a string variable called disease_ICD (oldvar) which has the values of "International Statistical Classification of Diseases and Related Health Problems – ICD 9 and ICD 10"

I need to create a new variable disease_ICDgroup (newvar) containing grouped values of disease_ICD (oldvar). The equivalent in EPI INFO is:

. Define newvar TEXTINPUT

. IF(substring(oldvar,1,3)>="001"AND substring(oldvar,1,3)<"799"THEN ASSIGN newvar ="1" END

. IF(substring(oldvar,1,3)>="A00"AND substring(oldvar,1,3)<"U99"THEN ASSIGN newvar ="1" END

. IF(substring(oldvar,1,3)>="800"AND substring(oldvar,1,3)<"999"THEN ASSIGN newvar ="2" END

. IF(substring(oldvar,1,3)>="V00"AND substring(oldvar,1,3)<"Y99"THEN ASSIGN newvar ="2" END

Note: The first three characters from oldvar are the same in all banks (more than 20 banks) which allowed me to create ranges and commands that can be used in all banks. 

How do I do this in STATA?

Use video conversation to talk face-to-face with Windows Live Messenger.
*   For searches and help try:

*   For searches and help try:

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