Statalist


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

st: RE: using the command substr in stata


From   "Matt Spittal" <Matt.Spittal@cancervic.org.au>
To   <statalist@hsphsun2.harvard.edu>
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 
matt.spittal@cancervic.org.au 




-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of carmen gamarra
Sent: Wednesday, 30 July 2008 9:50 AM
To: statalist@hsphsun2.harvard.edu
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
me.

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.
http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_072008
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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