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
Predicted probability and classification statistics for xlogitDear Statalist users, I have two question regarding the fixed effect logit in panel settings. 1) I…
Difference in Sargan after xtdpdsysIs it possilbe to compute difference in Sargan after xtdpdsys ? …
Reduce space between category in a graphHi all, I wonder how reduce the space between category in a graph, example: Code: clear all set m…
Job Posting for Research Fellow in Student Social Support R&D Lab at Harvard Kennedy SchoolJob Posting for Research Fellow – Data & Survey Analyst Student Social Support R&D Lab at th…
Chi-square problemHi! Help please! I have a table with variables "speciality", "city", and "status". I need to compare…
Subscribe to:
Post Comments (Atom)
0 Response to Excluding certain items/variables from query
Post a Comment