Hello, I have a big dataset and I am trying to analyse children with all congenital heart diseases(CHD). ICD9 code is "745.x" to "747.x ". There are 25 columns of diagnosis from DX1-DX25. I generated variable CHD using the following codes.
gen CHD=0
foreach var of varlist DX1-DX25 {
replace CHD=1 if (substr(`var',1,3) >= "745" & substr(`var',1,3) <= "747")
}
label var CHD "Congenital Heart Diseases"
I would like to remove the following codes from the previous CHD group- Excluding :" 746.86", "747.32", "747.6x"," 747.8x"
I tried to a couple of ways, but it threw me errors .
gen chd=0
forvalues j=1/25{
replace chd=1 if inlist(DX`j', >="745" & <"748" )
replace chd=0 if inlist(DX`j', "746.86", "747.32")
replace chd=0 if inlist(substr(DX,1,5),"747.6","747.8")
}
label variable chd " congenital heart diseases"
I also tried but that threw error as well:
gen chd=0
foreach var of varlist DX1-DX25 {
replace chd=1 if (substr(`var',1,3) >= "745" & substr(`var',1,3) <= "747")
replace chd=0 if (substr(`var',1,5)= "747.6","747.8") & (substr(`var',1,6)= "746.86","747.32")
}
label variable chd " congenital heart diseases"
I really appreciate your help.
Related Posts with Excluding certain items/variables from query
How to keep >2 observations over 2-yearsI wonder if anyone would be so kind as to help me with the appropriate syntax. I have a data set de…
Merging panel data with gravity data- What should it look like?Hi all, I'm not too familiar with using gravity data, so I am not sure what my dataset should look …
Center around the MedianGood afternoon, Is there a command that allows you to center around the median of a continuous vari…
prodest only estimated correctly elasticities once and now it gives only negative coefficientsDear Gabriele Rovigatti , I am estimating a production function on COMPUSTAT data for the U.S. and …
How to pass the parameters to stata plugin?How to pass the parameters to c++ linux stata plugin? …
Subscribe to:
Post Comments (Atom)
0 Response to Excluding certain items/variables from query
Post a Comment