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
Renaming variablesHi! I have a dataset, where my variables are named with _smallt2 or _larget2. I'm trying to rename …
est tab marginsDear all, I cannot have the results I want in the est tab output using : Code: quietly probit Y i.…
How to merge M&A data to 13f data?Hi all, I am new to STATA. I have difficulty in doing M&A analysis when I try to merge M&A …
Hausmand testHello everyone! I am relatively new to STATA and I have a problem regarding how to use the Hausman …
Reshape errorHi all, I need help in reshaping long (year2007-year2012). The desired outcome would be something l…
Subscribe to:
Post Comments (Atom)
0 Response to Excluding certain items/variables from query
Post a Comment