Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Need to simplfy the code for ICD9


From   Michael Stewart <michaelstewartresearch@gmail.com>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: Need to simplfy the code for ICD9
Date   Tue, 28 May 2013 01:12:07 -0400

Thank you very much for such a nice code
Sincerely
Mike

On Tue, May 28, 2013 at 1:02 AM, Kieran McCaul <kieran.mccaul@uwa.edu.au> wrote:
> ...
>
> I don't use the icd9 program when I'm working with ICD-coded disease variables, mainly because the data I work with spans over 40 years and so ICD8, ICD9, and ICD10 codes are used.
> I also tend not to worry about the number of lines of code when I'm dealing with ICD codes: readability is more important.
>
> I have 21 diagnosis variables, diagcode1 to diagcode21, all strings.
> The following flags cases of diabetes or diabetes-related conditions.
>
>
> gen byte diabdiag_flag=0
> forvalues i=1/22  {
>         qui replace diabdiag_flag=1 if  substr(diagcode`i',1,3)=="250"  /* 250   Diabetes mellitus */
>
>         qui replace diabdiag_flag=1 if sep_date >= mdy(7,1,1999) & ///
>                     (substr(diagcode`i',1,3)>="E10" & ///
>                      substr(diagcode`i',1,3)<="E14")                    /* (E10-E14) Diabetes mellitus */
> }
>
> gen byte diabcond_flag=0
> forvalues i=1/22  {
>         qui replace diabcond_flag=1 if  sep_date >= mdy(1,1,1979) & ///
>                     (substr(diagcode`i',1,5)=="357.2" | ///          /* 357.2  Polyneuropathy in diabetes */
>                      substr(diagcode`i',1,5)=="362.0" | ///          /* 362.0  Diabetic retinopathy       */
>                      substr(diagcode`i',1,6)=="366.41")              /* 366.41 Diabetic cataract          */
>
>         qui replace diabcond_flag=1 if  sep_date >= mdy(7,1,1999) & ///
>                     (substr(diagcode`i',1,5)=="H28.0" | ///         /* H28.0  Diabetic cataract          */
>                      substr(diagcode`i',1,5)=="H36.0" | ///         /* H36.0  Diabetic retinopathy       */
>                      substr(diagcode`i',1,5)=="M14.2" | ///         /* M14.2  Diabetic arthropathy       */
>                      substr(diagcode`i',1,5)=="N08.3")              /* N08.3  Glomerular disorders in diabetes mellitus */
> }
>
>
>
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Michael Stewart
> Sent: Tuesday, 28 May 2013 6:13 AM
> To: statalist
> Subject: st: Need to simplfy the code for ICD9
>
> Hi
> I am trying to find an efficient code for working with ICD9 doagnosis codes
>
> At present: To create a variable (1/0) which denotes if there is/are
> ICD9 codes for a disease in the ICD9 section of the database  , I am
> using a 4 step code  as folows
>
> Step-1:
>
> foreach x in SDX1 SDX2 SDX3 SDX4 SDX5 SDX6 SDX7 SDX8{
> icd9 generate disease_`x'= `x', range(296* 300* 309.1 311)
> }
>
> Step-2:
> egen disease_1=rowmax(disease_SDX1 disease_SDX2 disease_SDX3
> disease_SDX4 disease_SDX5 disease_SDX6 disease_SDX7 disease_SDX8)
>
> Step-3:
> egen disease=max(disease_1)
>
> Step-4:
> drop disease_SDX*  disease_1
>
> Is there a more elegant, code that can be executed in lesser number of steps .
>
> Please help me .
>
> --
> Thank you ,
> Yours Sincerely,
> Mike.
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/



-- 
Thank you ,
Yours Sincerely,
Mike.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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