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
Can I use the Heckman model?Dear Statalist, I'm encountering problem using the Heckman two stage model. My data is about invest…
Create a first.treat for DID with multiple periodsHi everyone, I have a panel data (1960 to 1980) with multiple locations (lgacodes) and am trying to…
From string date "DD/MM/YYYY" to month and year variablesHi, How can I convert strings like "01/03/1997", e.i. of type "DD/MM/YYYY", to a new numeric variab…
Log-rank testHi All, Can I please request some advice on the following. I have produced a Kaplan Meier Curve loo…
Pseudo R² for meqrlogit using mi estimateHey, I found the following code in this forum to get the pseudo R² for imputed data: Code: local …
Subscribe to:
Post Comments (Atom)
0 Response to Excluding certain items/variables from query
Post a Comment